speak.c \
audio-note.c \
help.c \
+ search.c \
mapper.c
osm2db_CFLAGS = $(EXPAT_CFLAGS) $(SQLITE_CFLAGS) $(GLIBGTK_CFLAGS)
#include "poi-gui.h"
#include "gps-panels.h"
#include "gps-conn.h"
+#include "search.h"
#include "help.h"
gboolean
unit2latlon(_center.unitx, _center.unity, lat, lon);
-poi_search_dialog(NULL, &poi, lat, lon);
+mapper_search_dialog(SEARCH_TYPE_POI, lat, lon);
return TRUE;
}
return TRUE;
}
+gboolean
+menu_cb_search_address(GtkAction *action)
+{
+gdouble lat, lon;
+
+unit2latlon(_center.unitx, _center.unity, lat, lon);
+mapper_search_dialog(SEARCH_TYPE_WAY, lat, lon);
+return TRUE;
+}
+
gboolean
cmenu_cb_loc_set_home(GtkAction * action)
{
gboolean cb_poi_add(GtkAction * action);
gboolean cb_poi_search(GtkAction *action);
+gboolean menu_cb_search_address(GtkAction *action);
/* Callbacks for the "Waypoint" context menu. */
gboolean cmenu_cb_way_show_latlon(GtkAction * action);
#ifndef _MAPPER_TYPES_H
#define _MAPPER_TYPES_H
+/** Generic search item list indexes */
+typedef enum {
+ ITEM_ID,
+ ITEM_CATID,
+ ITEM_LAT,
+ ITEM_LON,
+ ITEM_DIST,
+ ITEM_LATLON,
+ ITEM_LABEL,
+ ITEM_DESC,
+ ITEM_CATLAB,
+ ITEM_NUM_COLUMNS
+} item_list_id;
+
/** This enumerated type defines the supported types of repositories. */
typedef enum {
REPOTYPE_NONE, /* No URL set. */
CAT_NUM_COLUMNS
} CategoryList;
-/** POI list **/
-typedef enum {
- POI_POIID,
- POI_CATID,
- POI_LAT,
- POI_LON,
- POI_LATLON,
- POI_LABEL,
- POI_DESC,
- POI_CATLAB,
- POI_NUM_COLUMNS
-} POIList;
-
/** This enum defines the possible units we can use. */
typedef enum {
UNITS_KM,
void osm_set_way_range_from_speed(gfloat speed);
void osm_set_way_range(guint sr);
+gboolean osm_way_search(gdouble lat, gdouble lon, gchar *text, GtkListStore **store);
+
void osm_progress_set_widget(sqlite3 *db, GtkProgressBar *w);
gboolean osm_db_prepare(sqlite3 *db);
return cmb;
}
-static void
+void
poi_category_combo_populate(GtkWidget *cmb_category, guint cat_id, gboolean add_na)
{
GtkTreeIter active;
if (!model)
return TRUE;
-gtk_tree_model_get(model, &iter, POI_LAT, &lat, -1);
-gtk_tree_model_get(model, &iter, POI_LON, &lon, -1);
+gtk_tree_model_get(model, &iter, ITEM_LAT, &lat, -1);
+gtk_tree_model_get(model, &iter, ITEM_LON, &lon, -1);
map_center_latlon(lat, lon);
map_update_location_from_center();
return TRUE;
_dest.valid=TRUE;
-gtk_tree_model_get(model, &iter, POI_LAT, &_dest.lat, -1);
-gtk_tree_model_get(model, &iter, POI_LON, &_dest.lon, -1);
+gtk_tree_model_get(model, &iter, ITEM_LAT, &_dest.lat, -1);
+gtk_tree_model_get(model, &iter, ITEM_LON, &_dest.lon, -1);
map_update_location_from_center();
gtk_tree_selection_set_mode(gtk_tree_view_get_selection (GTK_TREE_VIEW(sd.list)), GTK_SELECTION_SINGLE);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(sd.list), TRUE);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(sd.list), TRUE);
-gtk_tree_view_set_search_column (GTK_TREE_VIEW(sd.list), POI_LABEL);
+gtk_tree_view_set_search_column (GTK_TREE_VIEW(sd.list), ITEM_LABEL);
renderer = gtk_cell_renderer_text_new();
-column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", POI_LATLON, NULL);
+column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", ITEM_LATLON, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(sd.list), column);
renderer = gtk_cell_renderer_text_new();
-column = gtk_tree_view_column_new_with_attributes(_("Label"), renderer, "text", POI_LABEL, NULL);
-gtk_tree_view_column_set_sort_column_id (column, POI_LABEL);
+column = gtk_tree_view_column_new_with_attributes(_("Label"), renderer, "text", ITEM_LABEL, NULL);
+gtk_tree_view_column_set_sort_column_id (column, ITEM_LABEL);
gtk_tree_view_append_column(GTK_TREE_VIEW(sd.list), column);
renderer = gtk_cell_renderer_text_new();
-column = gtk_tree_view_column_new_with_attributes(_("Category"), renderer, "text", POI_CATLAB, NULL);
-gtk_tree_view_column_set_sort_column_id (column, POI_CATLAB);
+column = gtk_tree_view_column_new_with_attributes(_("Category"), renderer, "text", ITEM_CATLAB, NULL);
+gtk_tree_view_column_set_sort_column_id (column, ITEM_CATLAB);
gtk_tree_view_append_column(GTK_TREE_VIEW(sd.list), column);
g_signal_connect(G_OBJECT(btn_search), "clicked", G_CALLBACK(poi_search_do_cb), &sd);
while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(sd.dialog))) {
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(sd.list)), NULL, &iter)) {
- gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_POIID, &(poi->poi_id), -1);
- gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_CATID, &(poi->cat_id), -1);
- gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_LAT, &(poi->lat), -1);
- gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_LON, &(poi->lon), -1);
- gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_LABEL, &(poi->label), -1);
- gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_DESC, &(poi->desc), -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, ITEM_ID, &(poi->poi_id), -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, ITEM_CATID, &(poi->cat_id), -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, ITEM_LAT, &(poi->lat), -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, ITEM_LON, &(poi->lon), -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, ITEM_LABEL, &(poi->label), -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, ITEM_DESC, &(poi->desc), -1);
selected = TRUE;
break;
} else {
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
gtk_tree_model_get(GTK_TREE_MODEL(store),
&iter,
- POI_POIID, &(poi->poi_id),
- POI_CATID, &(poi->cat_id),
- POI_LAT, &(poi->lat),
- POI_LON, &(poi->lon),
- POI_LABEL, &(poi->label),
- POI_DESC, &(poi->desc), -1);
+ ITEM_ID, &(poi->poi_id),
+ ITEM_CATID, &(poi->cat_id),
+ ITEM_LAT, &(poi->lat),
+ ITEM_LON, &(poi->lon),
+ ITEM_LABEL, &(poi->label),
+ ITEM_DESC, &(poi->desc), -1);
g_object_unref(G_OBJECT(store));
return TRUE;
break;
#include "poi.h"
gboolean poi_select(guint unitx, guint unity, poi_info *poi);
-gboolean poi_category_dialog(guint cat_id);
-gboolean poi_category_list();
gboolean poi_dialog(POIAction action, guint unitx, guint unity);
gboolean poi_search_dialog(GtkListStore *store, poi_info *poi, gdouble lat, gdouble lon);
gboolean poi_quick_dialog(guint unitx, guint unity);
+gboolean poi_category_dialog(guint cat_id);
+gboolean poi_category_list();
+
+void poi_category_combo_populate(GtkWidget *cmb_category, guint cat_id, gboolean add_na);
+GtkWidget *category_combo_new(void);
+
#endif
#include "db.h"
#include "osm.h"
#include "osm-db.h"
+#include "latlon.h"
static sqlite3 *poidb;
break;
}
-*store = gtk_list_store_new(POI_NUM_COLUMNS,
+*store = gtk_list_store_new(ITEM_NUM_COLUMNS,
G_TYPE_INT, /* POI ID */
G_TYPE_INT, /* Category ID */
G_TYPE_DOUBLE, /* Latitude */
G_TYPE_DOUBLE, /* Longitude */
+ G_TYPE_DOUBLE, /* Distance */
G_TYPE_STRING, /* Lat/Lon */
G_TYPE_STRING, /* POI Label */
G_TYPE_STRING, /* POI Desc. */
G_TYPE_STRING); /* Category Label */
while (SQLITE_ROW == sqlite3_step(sql)) {
- gdouble rlat, rlon;
+ gdouble rlat, rlon, dist;
rlat=sqlite3_column_double(sql, 0);
rlon=sqlite3_column_double(sql, 1);
lat_format(rlat, tmp1);
lon_format(rlon, tmp2);
+ dist=calculate_distance(lat, lon, rlat, rlon);
+
gtk_list_store_append(*store, &iter);
gtk_list_store_set(*store, &iter,
- POI_POIID, sqlite3_column_int(sql, 2),
- POI_CATID, sqlite3_column_int(sql, 5),
- POI_LAT, rlat,
- POI_LON, rlon,
- POI_LATLON, g_strdup_printf("%s, %s", tmp1, tmp2),
- POI_LABEL, sqlite3_column_text(sql, 3),
- POI_DESC, sqlite3_column_text(sql, 4),
- POI_CATLAB, sqlite3_column_text(sql, 6),
+ ITEM_ID, sqlite3_column_int(sql, 2),
+ ITEM_CATID, sqlite3_column_int(sql, 5),
+ ITEM_LAT, rlat,
+ ITEM_LON, rlon,
+ ITEM_DIST, dist,
+ ITEM_LATLON, g_strdup_printf("%s, %s", tmp1, tmp2),
+ ITEM_LABEL, sqlite3_column_text(sql, 3),
+ ITEM_DESC, sqlite3_column_text(sql, 4),
+ ITEM_CATLAB, sqlite3_column_text(sql, 6),
-1);
rows++;
}
return FALSE;
}
-*store = gtk_list_store_new(POI_NUM_COLUMNS,
+*store = gtk_list_store_new(ITEM_NUM_COLUMNS,
G_TYPE_INT, /* POI ID */
G_TYPE_INT, /* Category ID */
G_TYPE_DOUBLE, /* Latitude */
G_TYPE_DOUBLE, /* Longitude */
+ G_TYPE_DOUBLE, /* Dist */
G_TYPE_STRING, /* Lat/Lon */
- G_TYPE_STRING, /* POI Label */
- G_TYPE_STRING, /* POI Desc. */
+ G_TYPE_STRING, /* Label */
+ G_TYPE_STRING, /* Desc. */
G_TYPE_STRING); /* Category Label */
while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
- gdouble lat, lon;
+ gdouble lat, lon, dist=0;
lat = sqlite3_column_double(poisql.select_poi, 0);
lon = sqlite3_column_double(poisql.select_poi, 1);
gtk_list_store_append(*store, &iter);
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_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),
+ ITEM_ID, sqlite3_column_int(poisql.select_poi, 2),
+ ITEM_CATID, sqlite3_column_int(poisql.select_poi, 5),
+ ITEM_LAT, lat,
+ ITEM_LON, lon,
+ ITEM_DIST, dist,
+ ITEM_LATLON, g_strdup_printf("%s, %s", tmp1, tmp2),
+ ITEM_LABEL, sqlite3_column_text(poisql.select_poi, 3),
+ ITEM_DESC, sqlite3_column_text(poisql.select_poi, 4),
+ ITEM_CATLAB, sqlite3_column_text(poisql.select_poi, 6),
-1);
num_cats++;
}
" <menuitem action='goto_destination'/>"
" <menuitem action='goto_gps'/>"
" <separator/>"
-" <menuitem action='goto_address'/>"
+" <menuitem action='search_address'/>"
" <menuitem action='goto_latlon'/>"
" <menuitem action='goto_nearpoi'/>"
" <menuitem action='goto_nextway'/>"
" <separator/>"
" <toolitem action='poi_add'/>"
" <toolitem action='poi_quick_add'/>"
-" <toolitem action='poi_search'/>"
" <separator/>"
-#if 0
-" <toolitem action='view_fullscreen'/>"
+" <toolitem action='search_address'/>"
" <separator/>"
-#endif
" <toolitem action='view_zoom_in'/>"
" <toolitem action='view_zoom_out'/>"
+#ifdef WITH_DEVICE_770
" <toolitem action='view_zoom_normal'/>"
" <toolitem action='view_zoom_auto'/>"
+#endif
" <separator/>"
" </toolbar>"
"</ui>";
{"goto_home", GTK_STOCK_HOME, N_("_Home"), "<control>H", NULL, G_CALLBACK(menu_cb_goto_home) },
{"goto_destination", GTK_STOCK_JUMP_TO, N_("_Destination"), "<control>J", NULL, G_CALLBACK(menu_cb_goto_destination) },
{"goto_gps", NULL, N_("_GPS"), "<control>G", NULL, G_CALLBACK(menu_cb_goto_gps) },
- {"goto_address", GTK_STOCK_FIND, N_("Address..."), NULL, NULL, NULL },
+ {"search_address", GTK_STOCK_FIND, N_("Address..."), NULL, NULL, G_CALLBACK(menu_cb_search_address) },
{"goto_latlon", NULL, N_("Lat/Lon"), NULL, NULL, G_CALLBACK(menu_cb_goto_latlon) },
{"goto_nextway", NULL, N_("Next Waypoint"), NULL, NULL, G_CALLBACK(menu_cb_goto_nextway) },
{"goto_nearpoi", NULL, N_("Near POI"), NULL, NULL, G_CALLBACK(menu_cb_goto_nearpoi) },