]> err.no Git - mapper/commitdiff
Use a timeout to pulse the progress bar and just run the mainloop in the sqlite progr...
authorKaj-Michael Lang <milang@onion.tal.org>
Wed, 27 Feb 2008 16:59:57 +0000 (18:59 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Wed, 27 Feb 2008 16:59:57 +0000 (18:59 +0200)
src/osm-db.c

index 86124cd39dfc04e15b6775a1993602da5c042afe..25f7d49c6ca853623e79389efda8ff908e01475b 100644 (file)
@@ -39,7 +39,7 @@
 /* #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)
@@ -80,6 +80,7 @@ struct osm_place_cache {
 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);
@@ -103,12 +104,18 @@ else
 
 /*****************************************************************************/
 
-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;
 }
@@ -129,17 +136,27 @@ osm_progress_show(sqlite3 *db)
 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);
+}
 }
 
 /*****************************************************************************/