13 #include <glib/gstdio.h>
16 #include <gconf/gconf-client.h>
17 #include <libxml/parser.h>
26 #include "mapper-types.h"
32 struct _poi_categories {
34 const gchar *name, *desc, *icon, *color;
37 /* The default POI categories */
38 static struct _poi_categories default_poi_categories[] = {
39 { NODE_AMENITY_PARKING, "Parking", "Parking place for vehicles." , "vehicle/parking", "#2020ff" },
40 { NODE_AMENITY_FUEL, "Fuel", "Stations for purchasing fuel for vehicles." , "vehicle/fuel_station", "#4040f0" },
41 { NODE_AMENITY_SPEEDCAM, "Speed Cam", "Automatic speed cameras." , "vehicle/restrictions/speed_trap", "#ff0000" },
42 { NODE_AMENITY_HOSPITAL, "Hospital", "" , "health/hospital", "#ff4040" },
43 { NODE_AMENITY_PHARMACY, "Pharmacy", "Place to get drugs." , "health/pharmacy", "#40f040" },
44 { NODE_AMENITY_POLICE, "Police", "Police station" , "public/police", "#8570ff" },
45 { NODE_TOURISM_HOTEL, "Hotel", "Places to stay temporarily or for the night." , "accommodation/hotel", "#ba20ba" },
46 { NODE_TOURISM_HOSTEL, "Hostel", "Places to stay temporarily or for the night. Cheap." , "accommodation/hostel", "#ba30ba" },
47 { NODE_TOURISM_MOTEL, "Motel", "Places to stay temporarily or for the night. Cheap." , "accommodation/motel", "#ba40ba" },
48 { NODE_AMENITY_ATM, "ATM", "Automatic Teller Machine/Cashpoint." , "money/atm", "#40a040" },
49 { NODE_AMENITY_BANK, "Bank", "Place to take care of your money." , "money/bank", "#50b550" },
50 { NODE_AMENITY_POST, "Post office", "Place to handle mail." , "public/post_office", "#ff6868" },
51 { NODE_AMENITY_POST_BOX, "Post box", "Send letters." , "public/post_box", "#ff6060" },
52 { NODE_TOURISM_INFO, "Tourism info", "A place for tourists to get information." , "misc/information", "#4af04a" },
53 { NODE_AMENITY_TAXI, "Taxi station", "Get a Taxi here." , "", "#50ffff" },
54 { NODE_RAILWAY_STATION, "Railway station", "Transportation by train." , "transport/railway", "#fa7070" },
55 { NODE_RAILWAY_HALT, "Railway halt", "" , "transport/railway_small", "#f27777" },
56 { NODE_AMENITY_BUS_STATION, "Bus station", "Transportation by bus." , "transport/bus", "#f07070" },
57 { NODE_AMENITY_BOAT, "Harbour", "Transportation by boat." , "transport/ferry", "#9090ee" },
58 { NODE_AIRPORT_TERMINAL, "Airport", "Transportation by air." , "transport/airport", "#909099" },
59 { NODE_TOURISM_CAMP_SITE, "Camp site", "Place to go camping" , "accommodation/camping", "#90f080" },
60 { NODE_TOURISM_CARAVAN_SITE, "Caravan site", "" , "accommodation/camping/caravan", "#90ff80" },
61 { NODE_TOURISM_PICNIC_SITE, "Picnic", "Place to have a Picnic" , "recreation/picnic", "#a5f8e5" },
62 { NODE_AMENITY_FOOD, "Restaurant, Fast food", "Places to eat or drink." , "food/fastfood", "#e5960d" },
63 { NODE_AMENITY_PUB, "Pub, Disco, Club", "Place to drink and party." , "food/pub", "#f5960d" },
64 { NODE_AMENITY_CAFE, "Cafe", "Place to drink coffe or tee and eat." , "food/cafe", "#ff960d" },
65 { NODE_AMENITY_CINEMA, "Cinema", "Place to see movies" , "recreation/cinema", "#9090a0" },
66 { NODE_AMENITY_THEATRE, "Theatre", "Place to see people performing" , "recreation/theater", "#9595a5" },
67 { NODE_AMENITY_SHOP, "Shopping", "Places to shop or acquire services." , "shopping", "#61ef1b" },
68 { NODE_AMENITY_POW, "Place of Worchip", "" , "religion/church", "#7c5b0b" },
69 { NODE_TOURISM_THEME_PARK, "Theme Park", "Place to have fun and ride for example rollercoasters." , "recreation/theme_park", "#8eef1b" },
70 { NODE_AMENITY_COLLEGE, "College Campus/Building", "" , "education/college", "#813fdc" },
71 { NODE_AMENITY_SCHOOL, "School", "" , "education/school", "#813fdc" },
72 { NODE_AMENITY_LIBRARY, "Library", "Place to read and borrow books and magazines" , "shopping/rental/library", "#803090" },
73 { NODE_AMENITY_TOWNHALL, "Townhall", "" , "", "#408090" },
74 { NODE_AMENITY_WC, "WC/Toilets", "" , "public/toilets", "#e1d62c" },
75 { NODE_AMENITY_TELEPHONE, "Telephone", "Public telephone" , "public/telephone", "#208060" },
76 { NODE_TOURISM_ATTRACTION, "Attraction", "Something interesting" , "generic", "#004000" },
78 { NODE_SPORT_CENTER, "Sport Center", "" , "sports/centre", "#101080" },
79 { NODE_SPORT_STADIUM, "Sport Stadium", "" , "sports/stadium", "#101080" },
80 { NODE_SPORT_SKIING, "Skiing", "" , "sports/skiing", "#5050A0" },
81 { NODE_SPORT_SWIMMING, "Swimming", "" , "sports/swimming", "#102080" },
82 { NODE_SPORT_FOOTBALL, "Football", "" , "sports/football", "#102080" },
83 { NODE_SPORT_SOCCER, "Soccer", "" , "sports/soccer", "#102080" },
84 { NODE_SPORT_GOLF, "Golf", "" , "sports/golf", "#102080" },
85 { NODE_SPORT_TENNIS, "Tennis", "" , "sports/tennis", "#101080" },
86 { NODE_SPORT_BOWLING, "Bowling", "" , "", "#101080" },
87 { NODE_SPORT_RUGBY, "Rugby", "" , "", "#101080" },
88 { NODE_SPORT_CLIMBING, "Climbing", "" , "", "#101080" },
89 { NODE_SPORT_CYCLING, "Cycling", "" , "sports/bicycle", "#101080" },
90 { NODE_SPORT_MOTOR, "Motor sport", "" , "", "#101080" },
91 { NODE_SPORT_HOCKEY, "Hockey", "" , "", "#5050A0" },
92 { NODE_SPORT_SKATING, "Skating", "" , "", "#5050A0" },
93 { NODE_SPORT_SKATEBOARD, "Skateboard", "" , "", "#101080" },
94 { NODE_SPORT_HORSES, "Horses", "Horse riding or racing" , "sports/riding", "#101080" },
95 { NODE_SPORT_DOG, "Dog racing", "" , "", "#101080" },
96 { NODE_SPORT_BASKETBALL, "Basketball", "" , "", "#101080" },
97 { NODE_SPORT_BASEBALL, "Baseball", "" , "", "#101080" },
98 { NODE_SPORT_CANOE, "Canoe", "" , "", "#101080" },
99 { NODE_SPORT_CROQUET, "Croquet", "" , "", "#101080" },
100 { NODE_SPORT_CRICKET, "Cricket", "" , "", "#101080" },
101 { NODE_SPORT_SHOOTING, "Shooting", "Shooting range" , "", "#101080" },
102 { NODE_SPORT_PAINTBALL, "Paintball", "Run around and shoot people with paintballs" , "", "#101080" },
103 { NODE_SPORT_TABLE_TENNIS, "Table tennis", "" , "", "#101080" },
104 { NODE_SPORT_PELOTA, "Pelota", "" , "", "#101080" },
105 { NODE_SPORT_RACQUET, "Racquet", "" , "sports/racquetball", "#101080" },
106 { NODE_SPORT_BOWLS, "Lawn Bowls", "" , "", "#101080" },
107 { NODE_SPORT_ATHLETICS, "Athletics", "" , "", "#101080" },
108 { NODE_SPORT_OTHER, "Other Sports", "" , "", "#101077" },
110 { NODE_AMENITY_GENERIC, "Other", "Miscellaneous category for everything else." , "generic", "#002000" },
111 { NODE_POI_END, NULL, NULL }
115 poi_populate_categories(sqlite3 *db)
117 sqlite3_stmt *sql_cat;
120 g_printf("Checking default categories\n");
121 sqlite3_prepare_v2(db,"insert or replace into category (cat_id, label, desc, enabled, priority, icon, color)"
122 " values (?, ?, ?, 1, ?, ?, ?)",
125 for (i=0; default_poi_categories[i].name; i++) {
126 sqlite3_bind_int(sql_cat, 1, default_poi_categories[i].type);
127 sqlite3_bind_text(sql_cat, 2, default_poi_categories[i].name, -1, SQLITE_TRANSIENT);
128 sqlite3_bind_text(sql_cat, 3, default_poi_categories[i].desc, -1, SQLITE_TRANSIENT);
129 sqlite3_bind_int(sql_cat, 4, default_poi_categories[i].type/100);
130 sqlite3_bind_text(sql_cat, 5, default_poi_categories[i].icon, -1, SQLITE_TRANSIENT);
131 sqlite3_bind_text(sql_cat, 6, default_poi_categories[i].color, -1, SQLITE_TRANSIENT);
132 if (sqlite3_step(sql_cat)==SQLITE_OK)
133 g_printf("Failed to update category: %d [%s]\n", i, default_poi_categories[i].name);
134 sqlite3_reset(sql_cat);
135 sqlite3_clear_bindings(sql_cat);
138 sqlite3_finalize(sql_cat);
144 poi_db_create(sqlite3 *db)
149 if (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
150 &pszResult, &nRow, &nColumn, NULL)) {
153 g_printf("Creating initial tables\n");
155 create_sql = sqlite3_mprintf
157 "(poi_id integer PRIMARY KEY, "
164 "source integer default 0, "
165 "osm_id integer default 0, "
166 "priority integer default 2, "
168 "create table category (cat_id integer PRIMARY KEY,"
173 "priority integer default 2, "
174 "enabled integer);");
176 if (SQLITE_OK != sqlite3_exec(db, create_sql, NULL, NULL, NULL)
177 && (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
178 &pszResult, &nRow, &nColumn, NULL))) {
179 g_printf("%s:\n%s",_("Failed to open or create database"),sqlite3_errmsg(db));
185 sqlite3_free_table(pszResult);
188 /* Make sure default categories exists */
189 poi_populate_categories(db);
194 poi_db_prepare(sqlite3 *db)
196 /* select from poi */
197 sqlite3_prepare_v2(db,
198 "select p.lat, p.lon, p.poi_id, p.label, p.desc,"
199 " p.cat_id, c.label, c.desc, c.icon, c.color"
200 " from poi p, category c "
201 " where p.lat between ? and ? "
202 " and p.lon between ? and ? "
203 " and c.enabled = 1 and p.cat_id = c.cat_id",
204 -1, &poisql.select_poi, NULL);
206 /* select nearest pois */
207 sqlite3_prepare_v2(db,
208 "select p.lat, p.lon, p.label, c.label, c.icon, c.color"
209 " from poi p, category c "
210 " where c.enabled = 1 and p.cat_id = c.cat_id "
211 " and p.lat between $LAT-0.10 and $LAT+0.10 "
212 " and p.lon between $LON-0.10 and $LAT+0.10 "
213 " order by (($LAT - p.lat) * ($LAT - p.lat) "
214 "+ ($LON - p.lon) * ($LON - p.lon)) limit 1",
215 -1, &poisql.select_nearest_poi, NULL);
217 /* Search POI label */
218 sqlite3_prepare_v2(db,
219 "select p.lat, p.lon, p.poi_id, p.label, p.desc,"
220 " p.cat_id, c.label, c.desc, c.icon, c.color"
221 " from poi p, category c "
222 " where p.lat between ? and ? "
223 " and p.lon between ? and ? "
224 " and c.enabled = 1 and p.cat_id = c.cat_id and p.label like ?",
225 -1, &poisql.select_poi_search, NULL);
227 /* Search POI label && category */
228 sqlite3_prepare_v2(db,
229 "select p.lat, p.lon, p.poi_id, p.label, p.desc,"
230 " p.cat_id, c.label, c.desc, c.icon, c.color"
231 " from poi p, category c "
232 " where p.lat between ? and ? "
233 " and p.lon between ? and ? "
234 " and c.enabled = 1 and p.cat_id = c.cat_id and p.label like ? and c.cat_id = ?",
235 -1, &poisql.select_poi_search_cat, NULL);
238 sqlite3_prepare_v2(db,
239 "insert into poi (lat, lon, label, desc, cat_id, public)"
240 " values (?, ?, ?, ?, ?, 1)", -1, &poisql.insert_poi, NULL);
242 sqlite3_prepare_v2(db, "update poi set label = ?, desc = ?, "
243 "cat_id = ? where poi_id = ?",
244 -1, &poisql.update_poi, NULL);
245 /* delete from poi */
246 sqlite3_prepare_v2(db, "delete from poi where poi_id = ?",
247 -1, &poisql.delete_poi, NULL);
248 /* delete from poi by cat_id */
249 sqlite3_prepare_v2(db, "delete from poi where cat_id = ?",
250 -1, &poisql.delete_poi_by_catid, NULL);
251 /* get next poilabel */
252 sqlite3_prepare_v2(db, "select ifnull(max(poi_id) + 1,1) from poi",
253 -1, &poisql.nextlabel_poi, NULL);
255 /* select from category */
256 sqlite3_prepare_v2(db,
257 "select c.label, c.desc, c.enabled"
258 " from category c where c.cat_id = ?",
259 -1, &poisql.select_cat, NULL);
260 /* insert into category */
261 sqlite3_prepare_v2(db,
262 "insert into category (label, desc, enabled)"
263 " values (?, ?, ?)", -1, &poisql.insert_cat, NULL);
264 /* update category */
265 sqlite3_prepare_v2(db,
266 "update category set label = ?, desc = ?,"
267 " enabled = ? where poi_id = ?",
268 -1, &poisql.update_cat, NULL);
269 /* delete from category */
270 sqlite3_prepare_v2(db,"delete from category where cat_id = ?",
271 -1, &poisql.delete_cat, NULL);
272 /* enable category */
273 sqlite3_prepare_v2(db,
274 "update category set enabled = ?"
275 " where cat_id = ?", -1, &poisql.toggle_cat, NULL);
276 /* select all category */
277 sqlite3_prepare_v2(db,
278 "select c.cat_id, c.label, c.desc, c.enabled, c.icon, c.color,"
281 " left outer join poi p on c.cat_id = p.cat_id"
282 " group by c.cat_id, c.label, c.desc, c.enabled "
283 " order by c.priority,c.label", -1, &poisql.selall_cat, NULL);
285 /* Select quick categories */
286 sqlite3_prepare_v2(db,
287 "select c.cat_id, c.label, c.icon, c.color"
288 " from category c where c.enabled=1 "
289 " order by c.priority,c.label limit 9", -1, &poisql.select_quick_cat, NULL);
295 mapper_db_disconnect(sqlite3 **db)
298 /* XXX: Handle the prepared statements */
300 poi_db_unprepare(*db);
301 osm_db_unprepare(*db);
310 mapper_db_connect(sqlite3 **db, const gchar *data_db)
312 if (db_connect(db, data_db)) {
314 if (poi_db_prepare(*db)==FALSE) {
315 g_printerr("Failed to prepare POI SQL statements:");
316 g_printf("SQLITE: %s\n", sqlite3_errmsg(*db));
319 if (osm_db_prepare(*db)==FALSE) {
320 g_printerr("Failed to prepare OSM SQL statements:");
321 g_printf("SQLITE: %s\n", sqlite3_errmsg(*db));
332 return g_slice_new0(poi_info);
336 poi_free(poi_info *p)
338 g_slice_free(poi_info, p);
341 /*************************************
342 * POI Category functions
347 poi_category_new(void)
349 return g_slice_new0(poi_category);
353 poi_category_free(poi_category *c)
359 g_slice_free(poi_category, c);
363 poi_category_toggle(gint cat_id, gboolean cat_enabled)
365 if (SQLITE_OK != sqlite3_bind_int(poisql.toggle_cat, 1, cat_enabled) ||
366 SQLITE_OK != sqlite3_bind_int(poisql.toggle_cat, 2, cat_id) ||
367 SQLITE_DONE != sqlite3_step(poisql.toggle_cat)) {
374 poi_category_get(gint cat_id, poi_category **c)
378 if (SQLITE_OK != sqlite3_bind_int(poisql.select_cat, 1, cat_id)
379 || SQLITE_ROW != sqlite3_step(poisql.select_cat)) {
380 sqlite3_reset(poisql.select_cat);
384 cc=poi_category_new();
386 cc->label = g_strdup(sqlite3_column_text(poisql.select_cat, 0));
387 cc->desc = g_strdup(sqlite3_column_text(poisql.select_cat, 1));
388 cc->enabled = sqlite3_column_int(poisql.select_cat, 2);
390 sqlite3_reset(poisql.select_cat);
391 sqlite3_clear_bindings(poisql.select_cat);
397 poi_category_update(gint cat_id, poi_category *c)
399 gboolean results=TRUE;
407 sqlite3_bind_text(poisql.update_cat, 1, c->label, -1, g_free)
408 || SQLITE_OK != sqlite3_bind_text(poisql.update_cat, 2, c->desc, -1, g_free)
409 || SQLITE_OK != sqlite3_bind_int(poisql.update_cat, 3, c->enabled)
410 || SQLITE_OK != sqlite3_bind_int(poisql.update_cat, 4, c->id)
411 || SQLITE_DONE != sqlite3_step(poisql.update_cat)) {
414 sqlite3_reset(poisql.update_cat);
415 sqlite3_clear_bindings(poisql.update_cat);
419 sqlite3_bind_text(poisql.insert_cat, 1, c->label, -1, g_free)
420 || SQLITE_OK != sqlite3_bind_text(poisql.insert_cat, 2, c->desc, -1, g_free)
421 || SQLITE_OK != sqlite3_bind_int(poisql.insert_cat, 3, c->enabled)
422 || SQLITE_DONE != sqlite3_step(poisql.insert_cat)) {
425 sqlite3_reset(poisql.insert_cat);
426 sqlite3_clear_bindings(poisql.insert_cat);
432 poi_category_delete(delete_poi *dpoi)
437 if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi_by_catid, 1, dpoi->id)
438 || SQLITE_DONE != sqlite3_step(poisql.delete_poi_by_catid)) {
439 sqlite3_reset(poisql.delete_poi_by_catid);
442 sqlite3_reset(poisql.delete_poi_by_catid);
443 sqlite3_clear_bindings(poisql.delete_poi_by_catid);
445 if (SQLITE_OK != sqlite3_bind_int(poisql.delete_cat, 1, dpoi->id) ||
446 SQLITE_DONE != sqlite3_step(poisql.delete_cat)) {
447 sqlite3_reset(poisql.delete_cat);
450 sqlite3_reset(poisql.delete_cat);
451 sqlite3_clear_bindings(poisql.delete_cat);
457 poi_delete(delete_poi *dpoi)
462 if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi, 1, dpoi->id) ||
463 SQLITE_DONE != sqlite3_step(poisql.delete_poi)) {
464 sqlite3_reset(poisql.delete_poi);
467 sqlite3_reset(poisql.delete_poi);
468 sqlite3_clear_bindings(poisql.delete_poi);
474 poi_get_list(guint unitx, guint unity, GtkListStore **store, guint *_num_cats)
477 gdouble lat1, lon1, lat2, lon2;
479 gchar tmp1[16], tmp2[16];
485 *store = gtk_list_store_new(POI_NUM_COLUMNS, G_TYPE_INT, /* POI ID */
486 G_TYPE_INT, /* Category ID */
487 G_TYPE_DOUBLE, /* Latitude */
488 G_TYPE_DOUBLE, /* Longitude */
489 G_TYPE_STRING, /* Lat/Lon */
490 G_TYPE_STRING, /* POI Label */
491 G_TYPE_STRING, /* POI Desc. */
492 G_TYPE_STRING); /* Category Label */
494 x = unitx - pixel2unit(3 * _draw_width);
495 y = unity + pixel2unit(3 * _draw_width);
496 unit2latlon(x, y, lat1, lon1);
498 x = unitx + pixel2unit(3 * _draw_width);
499 y = unity - pixel2unit(3 * _draw_width);
500 unit2latlon(x, y, lat2, lon2);
502 if (SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 1, lat1) ||
503 SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 2, lat2) ||
504 SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 3, lon1) ||
505 SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 4, lon2)) {
506 g_printerr("Failed to bind values for poisql.select_poi\n");
510 while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
512 lat = sqlite3_column_double(poisql.select_poi, 0);
513 lon = sqlite3_column_double(poisql.select_poi, 1);
514 lat_format(lat, tmp1);
515 lon_format(lon, tmp2);
517 gtk_list_store_append(*store, &iter);
518 gtk_list_store_set(*store, &iter,
519 POI_POIID, sqlite3_column_int(poisql.select_poi, 2),
520 POI_CATID, sqlite3_column_int(poisql.select_poi, 5),
521 POI_LAT, lat, POI_LON, lon, POI_LATLON,
522 g_strdup_printf("%s, %s", tmp1, tmp2),
523 POI_LABEL, sqlite3_column_text(poisql.select_poi, 3),
524 POI_DESC, sqlite3_column_text(poisql.select_poi, 4),
525 POI_CATLAB, sqlite3_column_text(poisql.select_poi, 6),
529 sqlite3_reset(poisql.select_poi);
530 sqlite3_clear_bindings(poisql.select_poi);
536 poi_update(gint poi_id, gint cat_id, gchar *poi_label, gchar *poi_desc)
541 if (SQLITE_OK != sqlite3_bind_text(poisql.update_poi, 1, poi_label, -1, SQLITE_STATIC)
542 || SQLITE_OK != sqlite3_bind_text(poisql.update_poi, 2, poi_desc, -1, g_free)
543 || SQLITE_OK != sqlite3_bind_int(poisql.update_poi, 3, cat_id)
544 || SQLITE_OK != sqlite3_bind_int(poisql.update_poi, 4, poi_id)
545 || SQLITE_DONE != sqlite3_step(poisql.update_poi)) {
548 sqlite3_reset(poisql.update_poi);
549 sqlite3_clear_bindings(poisql.update_poi);
554 poi_add(gdouble lat, gdouble lon, gint cat_id, gchar *poi_label, gchar *poi_desc)
559 if (SQLITE_OK != sqlite3_bind_double(poisql.insert_poi, 1, lat)
560 || SQLITE_OK != sqlite3_bind_double(poisql.insert_poi, 2, lon)
561 || SQLITE_OK != sqlite3_bind_text(poisql.insert_poi, 3, poi_label, -1, g_free)
562 || SQLITE_OK != sqlite3_bind_text(poisql.insert_poi, 4, poi_desc, -1, g_free)
563 || SQLITE_OK != sqlite3_bind_int(poisql.insert_poi, 5, cat_id)
564 || SQLITE_DONE != sqlite3_step(poisql.insert_poi)) {
567 sqlite3_reset(poisql.insert_poi);
568 sqlite3_clear_bindings(poisql.insert_poi);
573 poi_find_nearest(gdouble lat, gdouble lon)
580 sqlite3_reset(poisql.select_nearest_poi);
581 sqlite3_clear_bindings(poisql.select_nearest_poi);
583 if (SQLITE_OK == sqlite3_bind_double(poisql.select_nearest_poi, 1, lat)
584 && SQLITE_OK == sqlite3_bind_double(poisql.select_nearest_poi, 2, lon)
585 && SQLITE_ROW == sqlite3_step(poisql.select_nearest_poi)) {
588 p->lat = sqlite3_column_double(poisql.select_nearest_poi, 0);
589 p->lon = sqlite3_column_double(poisql.select_nearest_poi, 1);
590 p->label=g_strdup(sqlite3_column_text(poisql.select_nearest_poi, 2));
591 p->cat_label=g_strdup(sqlite3_column_text(poisql.select_nearest_poi, 3));
598 poi_category_generate_store()
606 store = gtk_list_store_new(CAT_NUM_COLUMNS,
609 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);
611 while (SQLITE_ROW == sqlite3_step(poisql.selall_cat)) {
612 gtk_list_store_append(store, &iter);
613 gtk_list_store_set(store, &iter,
614 CAT_ID, sqlite3_column_int(poisql.selall_cat, 0),
615 CAT_ENABLED, sqlite3_column_int(poisql.selall_cat, 3),
616 CAT_LABEL, sqlite3_column_text(poisql.selall_cat, 1),
617 CAT_DESC, sqlite3_column_text(poisql.selall_cat, 2),
618 CAT_POI_CNT, sqlite3_column_int(poisql.selall_cat, 6), -1);
621 sqlite3_reset(poisql.selall_cat);
622 sqlite3_clear_bindings(poisql.selall_cat);