{ NODE_AMENITY_ATM, "ATM", },
};
-/* Argh... */
-static gdouble qp_lat, qp_lon;
+/* Quick POI information structure */
+typedef struct _poi_quick_data poi_quick_data;
+static struct _poi_quick_data {
+ GtkWidget *dialog;
+ GtkWidget *label;
+ gdouble lat;
+ gdouble lon;
+} qp;
static gboolean
category_delete(GtkWidget *widget, delete_poi *dpoi)
poi_category *c;
if (cat_id > 0) {
- if (poi_category_get(cat_id, &c)==FALSE)
+ if (poi_category_get(cat_id, &c)==FALSE) {
+ popup_error(_window, "Failed to get category.");
return FALSE;
+ }
dialog = gtk_dialog_new_with_buttons(_("Edit Category"),
GTK_WINDOW(_window),
gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60);
-desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
-
gtk_table_attach(GTK_TABLE(table), chk_enabled = gtk_check_button_new_with_label(_("Enabled")), 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
/* label */
gtk_entry_set_text(GTK_ENTRY(txt_label), c->label);
/* desc */
+desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
gtk_text_buffer_set_text(desc_txt, c->desc, -1);
/* enabled */
while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_label)))) {
c=poi_category_new();
- c->label = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_label)));
+ c->label=g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_label)));
} else {
popup_error(dialog,_("Please specify a name for the category."));
continue;
}
- gtk_text_buffer_get_iter_at_offset(desc_txt, &begin, 0);
- gtk_text_buffer_get_end_iter(desc_txt, &end);
+ gtk_text_buffer_get_bounds(desc_txt, &begin, &end);
c->desc = gtk_text_buffer_get_text(desc_txt, &begin, &end, TRUE);
c->enabled = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(chk_enabled)) ? 1 : 0);
if (results==FALSE)
popup_error(_window, _("Problem updating category"));
poi_category_free(c);
+
+ break;
}
-g_free(dpoi.txt_label);
-g_object_unref(desc_txt);
-gtk_widget_hide_all(dialog);
+if (dpoi.txt_label)
+ g_free(dpoi.txt_label);
+gtk_widget_destroy(dialog);
return results;
}
ossohelp_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_POICAT, _osso);
#endif
-gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
- btn_edit = gtk_button_new_with_label(_("Edit")));
-
-gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
- btn_add = gtk_button_new_with_label(_("Add")));
+gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_edit = gtk_button_new_with_label(_("Edit")));
+gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_add = gtk_button_new_with_label(_("Add")));
store = poi_category_generate_store();
return TRUE;
sw = gtk_scrolled_window_new(NULL, NULL);
-gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sw, TRUE, TRUE, 0);
tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
}
gboolean
-poi_delete_confirm(GtkWidget * widget, delete_poi * dpoi)
+poi_delete_confirm(GtkWidget *widget, delete_poi *dpoi)
{
GtkWidget *dialog;
guint i;
GtkTextIter begin, end;
delete_poi dpoi = { NULL, NULL, 0 };
PoiCategoryEditInfo pcedit;
+gchar tmp1[16], tmp2[16];
if (action == ACTION_EDIT_POI) {
- if (!poi_select(unitx, unity, &poi)) {
+ if (!poi_select(unitx, unity, &poi))
return FALSE;
- }
dialog = gtk_dialog_new_with_buttons(_("Edit POI"),
GTK_WINDOW(_window),
GTK_DIALOG_MODAL,
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT, NULL);
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
- btn_delete = gtk_button_new_with_label(_("Delete")));
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_delete = gtk_button_new_with_label(_("Delete")));
dpoi.dialog = dialog;
dpoi.txt_label = g_strdup(poi.label);
}
/* Set the p_latlon string. */
-{
- gchar tmp1[16], tmp2[16];
- lat_format(poi.lat, tmp1);
- lon_format(poi.lon, tmp2);
- p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
-}
+lat_format(poi.lat, tmp1);
+lon_format(poi.lon, tmp2);
+p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
-gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
- table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0);
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Lat, Lon")),
- 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Lat, Lon")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(p_latlon),
- 1, 3, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(p_latlon), 1, 3, 0, 1, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Label")),
- 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Label")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- txt_label = gtk_entry_new(),
- 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), txt_label = gtk_entry_new(), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Category")),
- 0, 1, 3, 4, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Category")), 0, 1, 3, 4, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- hbox = gtk_hbox_new(FALSE, 4),
- 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4);
cmb_category = category_combo_new();
gtk_box_pack_start(GTK_BOX(hbox), cmb_category, FALSE, FALSE, 4);
poi_quick_button_cb(GtkWidget *w, gpointer data)
{
guint cat_id;
-gtk_widget_destroy(dialog_qp);
+gchar *label;
cat_id=GPOINTER_TO_INT(data);
-/* poi_add frees the label and desc so strdup them */
-if (poi_add(qp_lat, qp_lon, cat_id, g_strdup("QP"), g_strdup("Quick POI, update information please."))==FALSE) {
+if (strlen(gtk_entry_get_text(GTK_ENTRY(qp.label)))>0) {
+ label=g_strdup(gtk_entry_get_text(GTK_ENTRY(qp.label)));
+} else {
+ label=g_strdup("");
+}
+
+/* poi_add frees the label and desc so strdup */
+if (poi_add(qp.lat, qp.lon, cat_id, label, g_strdup("Quick POI, update information please."))==FALSE) {
popup_error(_window, _("Problem adding POI"));
} else {
map_render_data();
+ gtk_widget_destroy(qp.dialog);
}
return TRUE;
GtkWidget *buttons[POI_QUICK_BUTTONS];
guint x,y;
-unit2latlon(unitx, unity, qp_lat, qp_lon);
+unit2latlon(unitx, unity, qp.lat, qp.lon);
-dialog_qp = gtk_dialog_new_with_buttons(_("Quick POI"),
+qp.dialog = gtk_dialog_new_with_buttons(_("Quick POI"),
GTK_WINDOW(_window),
GTK_DIALOG_MODAL,
GTK_STOCK_CANCEL,
#ifdef WITH_OSSO_NOTYET
/* Enable the help button. */
- ossohelp_dialog_help_enable(GTK_DIALOG(dialog_qp), HELP_ID_POIQUICK, _osso);
+ ossohelp_dialog_help_enable(GTK_DIALOG(qp.dialog), HELP_ID_POIQUICK, _osso);
#endif
-gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_qp)->vbox), table = gtk_table_new(3, 3, FALSE), TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(qp.dialog)->vbox), table = gtk_table_new(3, 3, FALSE), TRUE, TRUE, 0);
gtk_table_set_col_spacings(GTK_TABLE(table), 6);
gtk_table_set_row_spacings(GTK_TABLE(table), 6);
}
}
-gtk_widget_show_all(dialog_qp);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(qp.dialog)->vbox), qp.label = gtk_entry_new(), TRUE, TRUE, 0);
+gtk_widget_show_all(qp.dialog);
-if (GTK_RESPONSE_REJECT == gtk_dialog_run(GTK_DIALOG(dialog_qp))) {
- gtk_widget_destroy(dialog_qp);
+if (GTK_RESPONSE_REJECT == gtk_dialog_run(GTK_DIALOG(qp.dialog))) {
+ gtk_widget_destroy(qp.dialog);
return TRUE;
}
{ NODE_AMENITY_TOWNHALL, "Townhall", "" , "", "#408090" },
{ NODE_AMENITY_WC, "WC/Toilets", "" , "public/toilets", "#e1d62c" },
{ NODE_AMENITY_TELEPHONE, "Telephone", "Public telephone" , "public/telephone", "#208060" },
- { NODE_TOURISM_ATTRACTION, "Attraction", "Something interesting" , "generic", "#004000" },
+ { NODE_TOURISM_ATTRACTION, "Attraction", "Something interesting" , "generic", "#005000" },
+
+ { NODE_HISTORIC_MUSEUM, "Museum", "A place where objects of historical, artistic, or scientific interest are exhibited, preserved or studied." , "sightseeing/museum", "#202020" },
+ { NODE_HISTORIC_CASTLE, "Castle", "Historical building or group of building used for defense by military forces, whose main structures are walls and towers." , "sightseeing/castle", "#404040" },
{ NODE_SPORT_CENTER, "Sport Center", "" , "sports/centre", "#101080" },
{ NODE_SPORT_STADIUM, "Sport Stadium", "" , "sports/stadium", "#101080" },
sqlite3_stmt *sql_cat;
gint i;
-g_printf("Checking default categories\n");
sqlite3_prepare_v2(db,"insert or replace into category (cat_id, label, desc, enabled, priority, icon, color)"
" values (?, ?, ?, 1, ?, ?, ?)",
-1, &sql_cat, NULL);
for (i=0; default_poi_categories[i].name; i++) {
sqlite3_bind_int(sql_cat, 1, default_poi_categories[i].type);
- sqlite3_bind_text(sql_cat, 2, default_poi_categories[i].name, -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(sql_cat, 3, default_poi_categories[i].desc, -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(sql_cat, 2, default_poi_categories[i].name, -1, SQLITE_STATIC);
+ sqlite3_bind_text(sql_cat, 3, default_poi_categories[i].desc, -1, SQLITE_STATIC);
sqlite3_bind_int(sql_cat, 4, default_poi_categories[i].type/100);
- sqlite3_bind_text(sql_cat, 5, default_poi_categories[i].icon, -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(sql_cat, 6, default_poi_categories[i].color, -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(sql_cat, 5, default_poi_categories[i].icon, -1, SQLITE_STATIC);
+ sqlite3_bind_text(sql_cat, 6, default_poi_categories[i].color, -1, SQLITE_STATIC);
if (sqlite3_step(sql_cat)==SQLITE_OK)
g_printf("Failed to update category: %d [%s]\n", i, default_poi_categories[i].name);
sqlite3_reset(sql_cat);
&pszResult, &nRow, &nColumn, NULL)) {
gchar *create_sql;
- g_printf("Creating initial tables\n");
+ g_printerr("Creating initial POI tables\n");
create_sql = sqlite3_mprintf
("create table poi "
- "(poi_id integer PRIMARY KEY, "
+ "(poi_id INTEGER PRIMARY KEY AUTOINCREMENT, "
"lat real, "
"lon real, "
"elev real, "
"label text, "
"desc text, "
- "public integer, "
- "source integer default 0, "
- "osm_id integer default 0, "
- "priority integer default 2, "
- "cat_id integer);"
- "create table category (cat_id integer PRIMARY KEY,"
+ "public int, "
+ "source int default 0, "
+ "osm_id int default 0, "
+ "priority int default 2, "
+ "cat_id int);"
+ "create table category (cat_id INTEGER PRIMARY KEY AUTOINCREMENT,"
"label text, "
"desc text, "
"icon text, "
"color char(7), "
- "priority integer default 2, "
- "enabled integer);");
+ "priority int default 2, "
+ "enabled int);");
if (SQLITE_OK != sqlite3_exec(db, create_sql, NULL, NULL, NULL)
&& (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
"insert into poi (lat, lon, label, desc, cat_id, public)"
" values (?, ?, ?, ?, ?, 1)", -1, &poisql.insert_poi, NULL);
/* update poi */
- sqlite3_prepare_v2(db, "update poi set label = ?, desc = ?, "
- "cat_id = ? where poi_id = ?",
- -1, &poisql.update_poi, NULL);
+ sqlite3_prepare_v2(db, "update poi set label = ?, desc = ?, cat_id = ? where poi_id = ?", -1, &poisql.update_poi, NULL);
/* delete from poi */
- sqlite3_prepare_v2(db, "delete from poi where poi_id = ?",
- -1, &poisql.delete_poi, NULL);
+ sqlite3_prepare_v2(db, "delete from poi where poi_id = ?", -1, &poisql.delete_poi, NULL);
/* delete from poi by cat_id */
- sqlite3_prepare_v2(db, "delete from poi where cat_id = ?",
- -1, &poisql.delete_poi_by_catid, NULL);
+ sqlite3_prepare_v2(db, "delete from poi where cat_id = ?", -1, &poisql.delete_poi_by_catid, NULL);
/* get next poilabel */
- sqlite3_prepare_v2(db, "select ifnull(max(poi_id) + 1,1) from poi",
- -1, &poisql.nextlabel_poi, NULL);
+ sqlite3_prepare_v2(db, "select ifnull(max(poi_id) + 1,1) from poi", -1, &poisql.nextlabel_poi, NULL);
/* select from category */
sqlite3_prepare_v2(db,
if (cat_id > 0) {
/* edit category */
- if (SQLITE_OK !=
- sqlite3_bind_text(poisql.update_cat, 1, c->label, -1, g_free)
- || SQLITE_OK != sqlite3_bind_text(poisql.update_cat, 2, c->desc, -1, g_free)
+ if (SQLITE_OK != sqlite3_bind_text(poisql.update_cat, 1, c->label, -1, SQLITE_STATIC)
+ || SQLITE_OK != sqlite3_bind_text(poisql.update_cat, 2, c->desc, -1, SQLITE_STATIC)
|| SQLITE_OK != sqlite3_bind_int(poisql.update_cat, 3, c->enabled)
|| SQLITE_OK != sqlite3_bind_int(poisql.update_cat, 4, c->id)
|| SQLITE_DONE != sqlite3_step(poisql.update_cat)) {
sqlite3_clear_bindings(poisql.update_cat);
} else {
/* add category */
- if (SQLITE_OK !=
- sqlite3_bind_text(poisql.insert_cat, 1, c->label, -1, g_free)
- || SQLITE_OK != sqlite3_bind_text(poisql.insert_cat, 2, c->desc, -1, g_free)
+ if (SQLITE_OK != sqlite3_bind_text(poisql.insert_cat, 1, c->label, -1, SQLITE_STATIC)
+ || SQLITE_OK != sqlite3_bind_text(poisql.insert_cat, 2, c->desc, -1, SQLITE_STATIC)
|| SQLITE_OK != sqlite3_bind_int(poisql.insert_cat, 3, c->enabled)
|| SQLITE_DONE != sqlite3_step(poisql.insert_cat)) {
results = FALSE;
if (!_db)
return FALSE;
-if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi_by_catid, 1, dpoi->id)
- || SQLITE_DONE != sqlite3_step(poisql.delete_poi_by_catid)) {
- sqlite3_reset(poisql.delete_poi_by_catid);
- return FALSE;
+if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi_by_catid, 1, dpoi->id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi_by_catid)) {
+ sqlite3_reset(poisql.delete_poi_by_catid);
+ return FALSE;
}
sqlite3_reset(poisql.delete_poi_by_catid);
sqlite3_clear_bindings(poisql.delete_poi_by_catid);
-if (SQLITE_OK != sqlite3_bind_int(poisql.delete_cat, 1, dpoi->id) ||
- SQLITE_DONE != sqlite3_step(poisql.delete_cat)) {
+if (SQLITE_OK != sqlite3_bind_int(poisql.delete_cat, 1, dpoi->id) || SQLITE_DONE != sqlite3_step(poisql.delete_cat)) {
sqlite3_reset(poisql.delete_cat);
return FALSE;
}
if (!_db)
return FALSE;
-if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi, 1, dpoi->id) ||
- SQLITE_DONE != sqlite3_step(poisql.delete_poi)) {
+if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi, 1, dpoi->id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi)) {
sqlite3_reset(poisql.delete_poi);
return FALSE;
-} else {
- sqlite3_reset(poisql.delete_poi);
- sqlite3_clear_bindings(poisql.delete_poi);
}
+sqlite3_reset(poisql.delete_poi);
+sqlite3_clear_bindings(poisql.delete_poi);
return TRUE;
}
if (!_db)
return FALSE;
-*store = gtk_list_store_new(POI_NUM_COLUMNS, G_TYPE_INT, /* POI ID */
- G_TYPE_INT, /* Category ID */
- G_TYPE_DOUBLE, /* Latitude */
- G_TYPE_DOUBLE, /* Longitude */
- G_TYPE_STRING, /* Lat/Lon */
- G_TYPE_STRING, /* POI Label */
- G_TYPE_STRING, /* POI Desc. */
- G_TYPE_STRING); /* Category Label */
+*store = gtk_list_store_new(POI_NUM_COLUMNS,
+ G_TYPE_INT, /* POI ID */
+ G_TYPE_INT, /* Category ID */
+ G_TYPE_DOUBLE, /* Latitude */
+ G_TYPE_DOUBLE, /* Longitude */
+ G_TYPE_STRING, /* Lat/Lon */
+ G_TYPE_STRING, /* POI Label */
+ G_TYPE_STRING, /* POI Desc. */
+ G_TYPE_STRING); /* Category Label */
x = unitx - pixel2unit(3 * _draw_width);
y = unity + pixel2unit(3 * _draw_width);
while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
gdouble lat, lon;
+
lat = sqlite3_column_double(poisql.select_poi, 0);
lon = sqlite3_column_double(poisql.select_poi, 1);
lat_format(lat, tmp1);
gtk_list_store_set(*store, &iter,
POI_POIID, sqlite3_column_int(poisql.select_poi, 2),
POI_CATID, sqlite3_column_int(poisql.select_poi, 5),
- POI_LAT, lat, POI_LON, lon, POI_LATLON,
- g_strdup_printf("%s, %s", tmp1, tmp2),
+ POI_LAT, lat,
+ POI_LON, lon,
+ POI_LATLON, g_strdup_printf("%s, %s", tmp1, tmp2),
POI_LABEL, sqlite3_column_text(poisql.select_poi, 3),
POI_DESC, sqlite3_column_text(poisql.select_poi, 4),
POI_CATLAB, sqlite3_column_text(poisql.select_poi, 6),