107
get_poi_icon (poi_t *poi)
111
static GHashTable *icon_cache = NULL;
112
static GdkPixbuf *poi_icon_default = NULL;
115
/* Initialise icon-cache: */
116
icon_cache = g_hash_table_new (g_str_hash, g_str_equal);
119
if (!poi_icon_default) {
120
/* Initialise the default POI icon: */
121
poi_icon_default = gdk_pixbuf_new_from_file_at_size
122
(PACKAGE_PIXMAPS_DIR "/" PACKAGE "-poi.png",
128
icon = g_hash_table_lookup (icon_cache, poi->keywords);
132
g_build_filename (foxtrotgps_dir, "poi-icons", NULL);
134
/* Not all characters that might be in a POI's name
135
are suitable for use in icon-filenames, e.g.:
136
path-separators need to be escaped so that
137
a POI named something like "../../evil"
138
doesn't result in us reading/writing a file
139
somewhere where we shouldn't, and a number of
140
characters need to be escaped to allow files
141
to be stored on some filesystems like FAT.
143
char *icon_basename =
144
g_uri_escape_string (poi->keywords, NULL, TRUE);
147
g_build_filename (icon_dir, icon_basename, NULL);
149
g_free (icon_basename);
151
g_mkdir (icon_dir, 0777);
154
if (!g_file_test (icon_path, G_FILE_TEST_EXISTS)) {
155
pid_t mkvisualid_pid;
156
int mkvisualid_status;
158
char *autocache_dir =
159
g_build_filename (global_home_dir,
161
PACKAGE, "poi-icons",
164
g_mkdir_with_parents (autocache_dir, 0777);
165
/* Free autocache_dir later--we need to pass it
166
to mkvisualid, below... */
168
mkvisualid_pid = fork();
170
switch (mkvisualid_pid) {
172
execlp ("mkvisualid", "mkvisualid",
174
"--autocache-dir", autocache_dir,
175
"--output", icon_path,
177
"--outline-width=.2",
179
/* Don't use glyph-types that are
180
easily confused with streets: */
188
_exit (1); /* execlp failed */
190
waitpid (mkvisualid_pid, &mkvisualid_status, 0);
191
/* Fall through to cleanup... */
193
g_free (autocache_dir);
197
icon = gdk_pixbuf_new_from_file_at_size
198
(icon_path, 32, 32, NULL);
199
/*^Note that this is slightly bigger than
200
the `generic POI star' fallback-icon:
201
we budget an additional 25% of the icon-radius
202
for a border in case the icon needs one,
203
e.g.: to ensure contrast against the map.
209
g_hash_table_insert (icon_cache,
217
icon = poi_icon_default;
290
x - icon_width/2, y - icon_height/2,
180
292
GDK_RGB_DITHER_NONE, 0, 0);
184
296
gtk_widget_queue_draw_area (
298
x - icon_width/2, y - icon_height/2,
299
icon_width, icon_height);
189
301
printf("POI: %s lat %f - lon %f\n",p->keywords,p->lat_deg, p->lon_deg);
400
512
category = gtk_combo_box_get_active(combo_box);
401
513
subcategory = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox_subcat));
402
514
entry = lookup_widget(dialog, "entry13");
403
keyword_raw = gtk_entry_get_text(GTK_ENTRY(entry));
404
keyword = my_strescape(keyword_raw, NULL);
515
keyword = gtk_entry_get_text(GTK_ENTRY(entry));
405
516
text_view = GTK_TEXT_VIEW(lookup_widget(dialog, "textview1"));
406
517
buffer = gtk_text_view_get_buffer(text_view);
407
518
gtk_text_buffer_get_start_iter (buffer, &start);
408
519
gtk_text_buffer_get_end_iter (buffer, &end);
409
desc_raw = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
410
desc = my_strescape(desc_raw, NULL);
520
desc = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
411
521
radiobutton = lookup_widget(dialog, "radiobutton8");
412
522
price_range = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton))) ? 1 : price_range;
413
523
radiobutton = lookup_widget(dialog, "radiobutton9");
425
535
db = g_strconcat(foxtrotgps_dir, "/", POI_DB, NULL);
427
sql = g_strdup_printf(
537
sql = sqlite3_mprintf (
428
538
"INSERT INTO poi "
429
539
"(idmd5, lat, lon, visibility, cat, subcat, keywords, desc, price_range, extended_open) "
430
"VALUES ('%.0f%.0f',%f,%f,%d,%d,%d,'%s','%s',%d,%d)",
540
"VALUES ('%.0f%.0f',%f,%f,%d,%d,%d,%Q,%Q,%d,%d)",
431
541
rand1, rand2, lat_deg, lon_deg, visibility, category, subcategory,
432
542
keyword, desc, price_range, extended_open);
493
602
entry = lookup_widget(dialog, "entry19");
494
keyword_raw = gtk_entry_get_text(GTK_ENTRY(entry));
495
keyword = my_strescape(keyword_raw, NULL);
603
keyword = gtk_entry_get_text(GTK_ENTRY(entry));
496
604
text_view = GTK_TEXT_VIEW(lookup_widget(dialog, "textview2"));
497
605
buffer = gtk_text_view_get_buffer(text_view);
498
606
gtk_text_buffer_get_start_iter (buffer, &start);
499
607
gtk_text_buffer_get_end_iter (buffer, &end);
500
desc_raw = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
501
desc = my_strescape(desc_raw, NULL);
608
desc = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
504
611
db = g_strconcat(foxtrotgps_dir, "/", POI_DB, NULL);
508
sql = g_strdup_printf(
615
sql = sqlite3_mprintf (