From cad7ed084883029616a3d8dbad280d750f6461e1 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 7 Aug 2007 16:33:18 +0300 Subject: [PATCH] Use progress bar in toolbar on hildon and gtk builds. Use it for osm-db queries. Remove some debuging output. --- src/map.c | 21 ++++++++++++++------- src/osm-db.h | 2 ++ src/poi.c | 4 +++- src/ui-common.c | 11 ++++------- src/ui-common.h | 2 +- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/map.c b/src/map.c index e8f0f1c..62a4a39 100644 --- a/src/map.c +++ b/src/map.c @@ -27,6 +27,7 @@ #include "utils.h" #include "map.h" #include "osm.h" +#include "db.h" #include "osm-db.h" #include "poi.h" #include "route.h" @@ -613,7 +614,9 @@ map_render_tile(guint tilex, guint tiley, guint destx, guint desty, map_pixbuf_scale_inplace(pixbuf, zoff, (tilex - ((tilex >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff), (tiley - ((tiley >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff)); +#ifdef DEBUG g_printf("I: %s (%d)\n", buffer, zoff); +#endif } } } @@ -635,15 +638,10 @@ map_render_tile(guint tilex, guint tiley, guint destx, guint desty, gboolean map_render_tile_idle(map_tile_rdata *mtr) { -g_printf("IDLE RENDER\n"); map_render_tile(mtr->tilex, mtr->tiley, mtr->destx, mtr->desty, FALSE); -/* -gtk_widget_queue_draw_area(_map_widget, mtr->destx, mtr->desty, - TILE_SIZE_PIXELS, TILE_SIZE_PIXELS); -*/ +gtk_widget_queue_draw_area(_map_widget, mtr->destx, mtr->desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS); g_slice_free(map_tile_rdata, mtr); - return FALSE; } @@ -1411,12 +1409,19 @@ gint ilat, ilon; gdouble lat,lon, dist; PoiInfo *p; gboolean fs; +static gboolean inp=FALSE; -unit2latlon(x, y, lat, lon); +/* We run the gtk mainloop in progress callback so we can be called again, we don't like that */ +if (inp==TRUE) + return; +inp=TRUE; +unit2latlon(x, y, lat, lon); ilat=lat2mp_int(lat); ilon=lon2mp_int(lon); +osm_progress_set_widget(_db, _progress_item); + /* Check if we are still near the same way as last time */ if (map_loc.street && osm_way_distance(ilat, ilon, map_loc.street->node_f, map_loc.street->node_t, &dist)==TRUE) { if (dist>15000.0) { @@ -1466,6 +1471,8 @@ if (fs==TRUE && map_loc.secondary && map_loc.secondary->isin!=0) { } map_set_place_information(map_loc.street, map_loc.primary, map_loc.secondary, p); +osm_progress_set_widget(_db, NULL); +inp=FALSE; } gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event) diff --git a/src/osm-db.h b/src/osm-db.h index 14a02d6..2eea3e6 100644 --- a/src/osm-db.h +++ b/src/osm-db.h @@ -7,6 +7,8 @@ gboolean osm_init(void); void osm_deinit(void); +void osm_progress_set_widget(sqlite3 *db, GtkProgressBar *w); + gboolean osm_way_get_nodes(osm_way *w); gboolean osm_way_get_name(osm_way *w); gboolean osm_way_get_ref(osm_way *w); diff --git a/src/poi.c b/src/poi.c index 848d41f..325c867 100644 --- a/src/poi.c +++ b/src/poi.c @@ -273,8 +273,10 @@ if (db_connect(db, data_db)) { poi_db_create(*db); if (poi_db_prepare(*db)==FALSE) g_printerr("Failed to prepare POI SQL statements"); - if (osm_db_prepare(*db)==FALSE) + if (osm_db_prepare(*db)==FALSE) { g_printerr("Failed to prepare OSM SQL statements"); + g_printf("SQLITE: %s\n", sqlite3_errmsg(*db)); + } return TRUE; } return FALSE; diff --git a/src/ui-common.c b/src/ui-common.c index ec0c422..2e8afaa 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -708,18 +708,13 @@ g_signal_connect (_toolbar_fullscreen_item, "clicked", G_CALLBACK (cb_fullscreen gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), _toolbar_fullscreen_item, -1); #endif -item = gtk_separator_tool_item_new(); +item=gtk_separator_tool_item_new(); gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); -#ifndef WITH_HILDON -/* Add a progress bar to our toolbar if we are using plain gtk */ -item = gtk_tool_item_new(); +item=gtk_tool_item_new(); _progress_item=gtk_progress_bar_new(); gtk_container_add(item, _progress_item); gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); -#else -/* Hildon uses progress information box */ -#endif } void mapper_init_variables(void) @@ -910,6 +905,8 @@ void mapper_init(gint argc, gchar ** argv) gtk_widget_show_all(vbox_main); #endif + /* gtk_widget_hide(_progress_item); */ + gtk_box_pack_start(GTK_BOX(mapvbox), info_banner.container, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0); diff --git a/src/ui-common.h b/src/ui-common.h index e8a0b6d..728ba00 100644 --- a/src/ui-common.h +++ b/src/ui-common.h @@ -131,7 +131,7 @@ GtkWidget *_menu_poi_item; /* Toolbar items */ GtkToolItem *_toolbar_fullscreen_item; -GtkWidget *_progress_item; +GtkProgressBar *_progress_item; /* Menu items for the "Auto-Center" submenu. */ GtkWidget *_menu_ac_latlon_item; -- 2.39.5