/* #define DEBUG_OSM_TIME */
#define OSM_PLACE_CACHE_MAX_ITEMS (64)
-#define OSM_DB_PROGRESS_NUM (20000)
+#define OSM_DB_PROGRESS_NUM (15000)
/* Node search ranges */
#define OSM_RANGE_START (16384)
static struct osm_place_cache pcache;
static guint way_dist_range=OSM_RANGE_WAY;
+static gint sid=0;
osm_way_node *osm_way_get_prev_node(osm_way *w);
osm_way_node *osm_way_get_next_node(osm_way *w);
/*****************************************************************************/
-static int
-osm_progress(void *ud)
+static gboolean
+osm_progress_pulse(void)
{
if (!dbpw)
- return 0;
+ return FALSE;
gtk_progress_bar_pulse(dbpw);
+return TRUE;
+}
+
+static int
+osm_progress(void *ud)
+{
gtk_main_iteration_do(FALSE);
return 0;
}
if (!dbpw)
return;
gtk_progress_bar_set_text(dbpw, _("Searching..."));
+gtk_progress_bar_pulse(dbpw);
+gtk_main_iteration_do(FALSE);
sqlite3_progress_handler(db, OSM_DB_PROGRESS_NUM, osm_progress, NULL);
}
void
osm_progress_set_widget(sqlite3 *db, GtkProgressBar *w)
{
-if (dbpw!=NULL && w==NULL)
+if (dbpw!=NULL && w==NULL) {
osm_progress_hide(db);
+ if (sid!=0)
+ g_source_remove(sid);
+ sid=0;
+ dbpw=NULL;
+ return;
+}
dbpw=w;
-if (w!=NULL)
+if (w!=NULL) {
osm_progress_show(db);
+ sid=g_timeout_add(200, osm_progress_pulse, NULL);
+}
}
/*****************************************************************************/