[cairo-commit] roadster/src db.c, 1.18, 1.19 mainwindow.c, 1.31, 1.32 map.c, 1.33, 1.34 map.h, 1.12, 1.13 searchwindow.c, 1.14, 1.15

Ian McIntosh commit at pdx.freedesktop.org
Fri Mar 25 23:51:56 PST 2005


Committed by: ian

Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv4264/src

Modified Files:
	db.c mainwindow.c map.c map.h searchwindow.c 
Log Message:
	* src/mainwindow.c: Made zoom and history buttons (and menuitems) go insentitive when clicking them would do nothing.  Changed single-click on border to always scroll half of window width/height/diagonal.
	* src/map.c: Added map_can_zoom_in() and map_can_zoom_out().
	* src/searchwindow.c: Added a "no results" message.
	* src/db.c: Cleanup.


Index: db.c
===================================================================
RCS file: /cvs/cairo/roadster/src/db.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- db.c	23 Mar 2005 09:21:49 -0000	1.18
+++ db.c	26 Mar 2005 07:51:54 -0000	1.19
@@ -67,8 +67,6 @@
 // call once on program start-up
 void db_init()
 {
-//	g_pDBMutex = g_mutex_new();
-
 #ifdef HAVE_MYSQL_EMBED
 	gchar* pszDataDir = g_strdup_printf("%s/.roadster/data", g_get_home_dir());
 	gchar* pszSetDataDirCommand = g_strdup_printf("--datadir=%s", pszDataDir);

Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- mainwindow.c	25 Mar 2005 22:02:11 -0000	1.31
+++ mainwindow.c	26 Mar 2005 07:51:54 -0000	1.32
@@ -67,7 +67,6 @@
 
 #define SCROLL_TIMEOUT_MS		(80)		// how often (in MS) to move
 #define SCROLL_DISTANCE_IN_PIXELS	(120)		// how far to move every (above) MS
-#define SCROLL_SINGLE_CLICK_DISTANCE_IN_PIXELS	(500)	// how to move in response to a single border click
 #define BORDER_SCROLL_CLICK_TARGET_SIZE	(20)		// the size of the click target (distance from edge of map view) to begin scrolling
 
 #define SLIDE_TIMEOUT_MS		(50)	// time between frames (in MS) for smooth-sliding (on double click?)
@@ -117,7 +116,6 @@
 static gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer pData);
 static gboolean mainwindow_callback_on_slide_timeout(gpointer pData);
 static void mainwindow_setup_selected_tool(void);
-
 static gboolean mainwindow_on_enter_notify(GtkWidget* w, GdkEventCrossing *event);
 static gboolean mainwindow_on_leave_notify(GtkWidget* w, GdkEventCrossing *event);
 
@@ -126,6 +124,8 @@
 void mainwindow_map_center_on_mappoint(mappoint_t* pPoint);
 void mainwindow_map_center_on_windowpoint(gint nX, gint nY);
 
+void mainwindow_on_zoomscale_value_changed(GtkRange *range, gpointer user_data);
+
 struct {
 	gint m_nX;
 	gint m_nY;
@@ -149,6 +149,11 @@
 	GtkImage* m_pStatusbarGPSIcon;
 	GtkWidget *m_pSidebox;
 
+	GtkButton* m_pZoomInButton;
+	GtkMenuItem* m_pZoomInMenuItem;
+	GtkButton* m_pZoomOutButton;
+	GtkMenuItem* m_pZoomOutMenuItem;
+
 	// Sidebar
 
 	// "Draw" Sidebar
@@ -157,7 +162,7 @@
 	GtkNotebook* m_pSidebarNotebook;
 
 	// "GPS" sidebar
-	GtkLabel* m_pSpeedLabel;
+	GtkLabel* m_pSpeedLabel;	// these belong in m_GPS
 	GtkProgressBar* m_pGPSSignalStrengthProgressBar;
 
 	struct {
@@ -206,6 +211,8 @@
 	history_t* m_pHistory;
 	GtkButton* m_pForwardButton;
 	GtkButton* m_pBackButton;
+	GtkMenuItem* m_pForwardMenuItem;
+	GtkMenuItem* m_pBackMenuItem;
 } g_MainWindow = {0};
 
 
@@ -268,10 +275,17 @@
 
 void mainwindow_init(GladeXML* pGladeXML)
 {
+	// Widgets
 	g_MainWindow.m_pWindow				= GTK_WINDOW(glade_xml_get_widget(pGladeXML, "mainwindow"));			g_return_if_fail(g_MainWindow.m_pWindow != NULL);
 	g_MainWindow.m_pMapPopupMenu		= GTK_MENU(glade_xml_get_widget(pGladeXML, "mappopupmenu"));			g_return_if_fail(g_MainWindow.m_pMapPopupMenu != NULL);
 	g_MainWindow.m_pPointerToolButton 	= GTK_TOOL_BUTTON(glade_xml_get_widget(pGladeXML, "pointertoolbutton"));g_return_if_fail(g_MainWindow.m_pPointerToolButton != NULL);
 	g_MainWindow.m_pZoomToolButton 		= GTK_TOOL_BUTTON(glade_xml_get_widget(pGladeXML, "zoomtoolbutton")); 	g_return_if_fail(g_MainWindow.m_pZoomToolButton != NULL);
+
+	g_MainWindow.m_pZoomInButton		= GTK_BUTTON(glade_xml_get_widget(pGladeXML, "zoominbutton")); 	g_return_if_fail(g_MainWindow.m_pZoomInButton != NULL);
+	g_MainWindow.m_pZoomInMenuItem		= GTK_MENU_ITEM(glade_xml_get_widget(pGladeXML, "zoominmenuitem")); 	g_return_if_fail(g_MainWindow.m_pZoomInMenuItem != NULL);
+	g_MainWindow.m_pZoomOutButton		= GTK_BUTTON(glade_xml_get_widget(pGladeXML, "zoomoutbutton")); 	g_return_if_fail(g_MainWindow.m_pZoomOutButton != NULL);
+	g_MainWindow.m_pZoomOutMenuItem		= GTK_MENU_ITEM(glade_xml_get_widget(pGladeXML, "zoomoutmenuitem")); 	g_return_if_fail(g_MainWindow.m_pZoomOutMenuItem != NULL);
+
 	g_MainWindow.m_pContentBox 			= GTK_HBOX(glade_xml_get_widget(pGladeXML, "mainwindowcontentsbox"));	g_return_if_fail(g_MainWindow.m_pContentBox != NULL);
 	g_MainWindow.m_pLocationSetsTreeView= GTK_TREE_VIEW(glade_xml_get_widget(pGladeXML, "locationsetstreeview"));	g_return_if_fail(g_MainWindow.m_pLocationSetsTreeView != NULL);
 	g_MainWindow.m_pLayersListTreeView	= GTK_TREE_VIEW(glade_xml_get_widget(pGladeXML, "layerstreeview"));		g_return_if_fail(g_MainWindow.m_pLayersListTreeView != NULL);
@@ -283,19 +297,22 @@
 	g_MainWindow.m_pStatusbar			= GTK_VBOX(glade_xml_get_widget(pGladeXML, "statusbar"));				g_return_if_fail(g_MainWindow.m_pStatusbar != NULL);
 	g_MainWindow.m_pSidebox				= GTK_WIDGET(glade_xml_get_widget(pGladeXML, "mainwindowsidebox"));		g_return_if_fail(g_MainWindow.m_pSidebox != NULL);
 	g_MainWindow.m_pSidebarNotebook			= GTK_NOTEBOOK(glade_xml_get_widget(pGladeXML, "sidebarnotebook"));		g_return_if_fail(g_MainWindow.m_pSidebarNotebook != NULL);
-//	g_MainWindow.m_pSearchBox			= GTK_ENTRY(glade_xml_get_widget(pGladeXML, "searchbox"));		g_return_if_fail(g_MainWindow.m_pSearchBox != NULL);
-//	g_MainWindow.m_pProgressBar			= GTK_PROGRESS_BAR(glade_xml_get_widget(pGladeXML, "mainwindowprogressbar"));		g_return_if_fail(g_MainWindow.m_pProgressBar != NULL);
 	g_MainWindow.m_pTooltips			= gtk_tooltips_new();
 	g_MainWindow.m_pSpeedLabel			= GTK_LABEL(glade_xml_get_widget(pGladeXML, "speedlabel"));		g_return_if_fail(g_MainWindow.m_pSpeedLabel != NULL);
-	g_MainWindow.m_pGPSSignalStrengthProgressBar = GTK_PROGRESS_BAR(glade_xml_get_widget(pGladeXML, "gpssignalprogressbar"));		g_return_if_fail(g_MainWindow.m_pGPSSignalStrengthProgressBar != NULL);
 
+	// GPS Widgets
 	g_MainWindow.m_GPS.m_pShowPositionCheckButton	= GTK_CHECK_BUTTON(glade_xml_get_widget(pGladeXML, "gpsshowpositioncheckbutton"));		g_return_if_fail(g_MainWindow.m_GPS.m_pShowPositionCheckButton != NULL);
 	g_MainWindow.m_GPS.m_pKeepPositionCenteredCheckButton= GTK_CHECK_BUTTON(glade_xml_get_widget(pGladeXML, "gpskeeppositioncenteredcheckbutton"));		g_return_if_fail(g_MainWindow.m_GPS.m_pKeepPositionCenteredCheckButton != NULL);
 	g_MainWindow.m_GPS.m_pShowTrailCheckButton = GTK_CHECK_BUTTON(glade_xml_get_widget(pGladeXML, "gpsshowtrailcheckbutton"));		g_return_if_fail(g_MainWindow.m_GPS.m_pKeepPositionCenteredCheckButton != NULL);
 	g_MainWindow.m_GPS.m_pStickToRoadsCheckButton = GTK_CHECK_BUTTON(glade_xml_get_widget(pGladeXML, "gpssticktoroadscheckbutton"));		g_return_if_fail(g_MainWindow.m_GPS.m_pStickToRoadsCheckButton != NULL);
+	g_MainWindow.m_pGPSSignalStrengthProgressBar = GTK_PROGRESS_BAR(glade_xml_get_widget(pGladeXML, "gpssignalprogressbar"));		g_return_if_fail(g_MainWindow.m_pGPSSignalStrengthProgressBar != NULL);
 
+	// History Widgets
 	g_MainWindow.m_pForwardButton = GTK_BUTTON(glade_xml_get_widget(pGladeXML, "forwardbutton"));		g_return_if_fail(g_MainWindow.m_pForwardButton != NULL);
 	g_MainWindow.m_pBackButton = GTK_BUTTON(glade_xml_get_widget(pGladeXML, "backbutton"));		g_return_if_fail(g_MainWindow.m_pBackButton != NULL);
+	g_MainWindow.m_pForwardMenuItem = GTK_MENU_ITEM(glade_xml_get_widget(pGladeXML, "forwardmenuitem"));		g_return_if_fail(g_MainWindow.m_pForwardMenuItem != NULL);
+	g_MainWindow.m_pBackMenuItem = GTK_MENU_ITEM(glade_xml_get_widget(pGladeXML, "backmenuitem"));		g_return_if_fail(g_MainWindow.m_pBackMenuItem != NULL);
+
 	g_MainWindow.m_pHistory = history_new();
 	g_assert(g_MainWindow.m_pHistory);
 
@@ -451,7 +468,6 @@
 	g_assert(g_MainWindow.m_nDrawPrettyTimeoutID != 0);
 }
 
-
 //
 // the "scroll" timeout
 //
@@ -599,25 +615,17 @@
 	return FALSE; // satisfy strick compiler
 }
 
-// the range slider changed value
-void mainwindow_on_zoomscale_value_changed(GtkRange *range, gpointer user_data)
-{
-	gdouble fValue = gtk_range_get_value(range);
-	gint16 nValue = (gint16)fValue;
-	gtk_range_set_value(range, (gdouble)nValue);
-
-	map_set_zoomlevel(g_MainWindow.m_pMap, nValue);
-	mainwindow_statusbar_update_zoomscale();
-
-	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
-	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
-
-	mainwindow_add_history();
-}
-
 //
 // Zoom
 //
+void mainwindow_update_zoom_buttons()
+{
+	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pZoomInButton), map_can_zoom_in(g_MainWindow.m_pMap));
+	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pZoomInMenuItem), map_can_zoom_in(g_MainWindow.m_pMap));
+	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pZoomOutButton), map_can_zoom_out(g_MainWindow.m_pMap));
+	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pZoomOutMenuItem), map_can_zoom_out(g_MainWindow.m_pMap));
+}
+
 void mainwindow_set_zoomlevel(gint nZoomLevel)
 {
 	map_set_zoomlevel(g_MainWindow.m_pMap, nZoomLevel);
@@ -628,24 +636,23 @@
 	g_signal_handlers_unblock_by_func(g_MainWindow.m_pZoomScale, mainwindow_on_zoomscale_value_changed, NULL);
 
 	mainwindow_statusbar_update_zoomscale();
+	mainwindow_update_zoom_buttons();
 }
 
-static void zoom_in_one(void)
+// the range slider changed value
+void mainwindow_on_zoomscale_value_changed(GtkRange *range, gpointer user_data)
 {
-	// tell the map
-	map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) + 1);
-	// tell the GUI
-	mainwindow_set_zoomlevel(map_get_zoomlevel(g_MainWindow.m_pMap));
+	gdouble fValue = gtk_range_get_value(range);
+	gint16 nValue = (gint16)fValue;
 
-	// NOTE: doesn't trigger an actual redraw
-}
+	// update GUI
+	mainwindow_set_zoomlevel(nValue);
 
-static void zoom_out_one(void)
-{
-	map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) - 1 );
-	mainwindow_set_zoomlevel(map_get_zoomlevel(g_MainWindow.m_pMap));
+	// also redraw immediately and add history item
+	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
+	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 
-	// NOTE: doesn't trigger an actual redraw
+	mainwindow_add_history();
 }
 
 //
@@ -696,7 +703,9 @@
 // Zoom buttons / menu items (shared callbacks)
 void mainwindow_on_zoomin_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
-	zoom_in_one();
+	// tell the map
+	map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) + 1);
+	mainwindow_set_zoomlevel(map_get_zoomlevel(g_MainWindow.m_pMap));
 	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
 	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 	mainwindow_add_history();
@@ -704,7 +713,8 @@
 
 void mainwindow_on_zoomout_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
-	zoom_out_one();
+	map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) - 1);
+	mainwindow_set_zoomlevel(map_get_zoomlevel(g_MainWindow.m_pMap));
 	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
 	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 	mainwindow_add_history();
@@ -873,7 +883,25 @@
 					mainwindow_draw_map(DRAWFLAG_ALL);
 				}
 				else {
-					mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_SINGLE_CLICK_DISTANCE_IN_PIXELS);
+					// user clicked the edge of the screen, but so far we haven't moved at all (they released the button too fast)
+					// so consider this a 'click' and just jump a bit in that direction
+					gint nHeight = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height;
+					gint nWidth = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width;
+
+					gint nDistanceInPixels;
+					if(g_MainWindow.m_eScrollDirection == DIRECTION_N || g_MainWindow.m_eScrollDirection == DIRECTION_S) {
+						// scroll half the height of the screen
+						nDistanceInPixels = nHeight/2;
+					}
+					else if(g_MainWindow.m_eScrollDirection == DIRECTION_E || g_MainWindow.m_eScrollDirection == DIRECTION_W) {
+						nDistanceInPixels = nWidth/2;
+					}
+					else {
+						// half the distance from corner to opposite corner
+						nDistanceInPixels = sqrt(nHeight*nHeight + nWidth*nWidth)/2;
+					}
+
+					mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, nDistanceInPixels);
 				}
 				g_MainWindow.m_eScrollDirection = DIRECTION_NONE;
 				mainwindow_add_history();
@@ -1031,12 +1059,14 @@
 {
 	// respond to scroll wheel events by zooming in and out
 	if(event->direction == GDK_SCROLL_UP) {
-		zoom_in_one();
+		map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) + 1);
+		mainwindow_set_zoomlevel(map_get_zoomlevel(g_MainWindow.m_pMap));
 		mainwindow_draw_map(DRAWFLAG_GEOMETRY);
 		mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 	}
 	else if(event->direction == GDK_SCROLL_DOWN) {
-		zoom_out_one();
+		map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) - 1);
+		mainwindow_set_zoomlevel(map_get_zoomlevel(g_MainWindow.m_pMap));
 		mainwindow_draw_map(DRAWFLAG_GEOMETRY);
 		mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
 	}
@@ -1374,10 +1404,16 @@
 	gtk_notebook_set_current_page(g_MainWindow.m_pSidebarNotebook, nTab);
 }
 
+//
+// History (forward / back buttons)
+//
 void mainwindow_update_forward_back_buttons()
 {
 	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pForwardButton), history_can_go_forward(g_MainWindow.m_pHistory));
 	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pBackButton), history_can_go_back(g_MainWindow.m_pHistory));
+
+	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pForwardMenuItem), history_can_go_forward(g_MainWindow.m_pHistory));
+	gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.m_pBackMenuItem), history_can_go_back(g_MainWindow.m_pHistory));
 }
 
 void mainwindow_go_to_current_history_item()
@@ -1420,9 +1456,9 @@
 	mainwindow_update_forward_back_buttons();
 }
 
-// Add the current spot to the history
 void mainwindow_add_history()
 {
+	// add the current spot to the history
 	mappoint_t point;
 
 	map_get_centerpoint(g_MainWindow.m_pMap, &point);
@@ -1430,6 +1466,7 @@
 
 	mainwindow_update_forward_back_buttons();
 }
+
 #ifdef ROADSTER_DEAD_CODE
 /*
 

Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- map.c	25 Mar 2005 22:02:11 -0000	1.33
+++ map.c	26 Mar 2005 07:51:54 -0000	1.34
@@ -556,7 +556,7 @@
 			g_ptr_array_add(
 				pMap->m_apLayerData[nTypeID]->m_pPointStringsArray, pNewPointString);
 		} // end while loop on rows
-		g_print("[%d rows]\n", uRowCount);
+		//g_print("[%d rows]\n", uRowCount);
 		TIMER_SHOW(mytimer, "after rows retrieved");
 
 		db_free_result(pResultSet);
@@ -781,3 +781,15 @@
 	}
 	return FALSE;
 }
+
+gboolean map_can_zoom_in(map_t* pMap)
+{
+	// can we increase zoom level?
+	return (pMap->m_uZoomLevel < MAX_ZOOMLEVEL);
+}
+gboolean map_can_zoom_out(map_t* pMap)
+{
+	return (pMap->m_uZoomLevel > MIN_ZOOMLEVEL);
+}
+
+

Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- map.h	25 Mar 2005 22:02:11 -0000	1.12
+++ map.h	26 Mar 2005 07:51:54 -0000	1.13
@@ -225,4 +225,7 @@
 
 gboolean map_hit_test(map_t* pMap, mappoint_t* pMapPoint, gchar** ppReturnString);
 
+gboolean map_can_zoom_in(map_t* pMap);
+gboolean map_can_zoom_out(map_t* pMap);
+
 #endif

Index: searchwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/searchwindow.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- searchwindow.c	20 Mar 2005 03:37:09 -0000	1.14
+++ searchwindow.c	26 Mar 2005 07:51:54 -0000	1.15
@@ -40,6 +40,7 @@
 #define RESULTLIST_LONGITUDE	2
 #define RESULTLIST_DISTANCE	3
 #define RESULTLIST_ZOOMLEVEL	4
+#define RESULTLIST_CLICKABLE	5
 
 #define MAGIC_GTK_NO_SORT_COLUMN (-2)	// why -2?  dunno.  is there a real define for this?  dunno.
 
@@ -56,6 +57,8 @@
 	// results list (on the sidebar)
 	GtkTreeView* m_pResultsTreeView;
 	GtkListStore* m_pResultsListStore;
+
+	gint m_nNumResults;
 } g_SearchWindow = {0};
 
 static void searchwindow_on_resultslist_selection_changed(GtkTreeSelection *treeselection, gpointer user_data);
@@ -67,7 +70,7 @@
 	g_SearchWindow.m_pResultsTreeView	= GTK_TREE_VIEW(glade_xml_get_widget(pGladeXML, "searchresultstreeview"));	g_return_if_fail(g_SearchWindow.m_pResultsTreeView != NULL);	
 
 	// create results tree view
-	g_SearchWindow.m_pResultsListStore = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_INT);
+	g_SearchWindow.m_pResultsListStore = gtk_list_store_new(6, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_INT, G_TYPE_BOOLEAN);
 	gtk_tree_view_set_model(g_SearchWindow.m_pResultsTreeView, GTK_TREE_MODEL(g_SearchWindow.m_pResultsListStore));
 
 	GtkCellRenderer* pCellRenderer;
@@ -89,6 +92,7 @@
 	if(g_SearchWindow.m_pResultsListStore != NULL) {
 		gtk_list_store_clear(g_SearchWindow.m_pResultsListStore);
 	}
+	g_SearchWindow.m_nNumResults = 0;
 }
 
 // begin a search
@@ -104,6 +108,18 @@
 	search_road_execute(pszSearch);
 	mainwindow_set_not_busy(&pBusy);
 
+	if(g_SearchWindow.m_nNumResults == 0) {
+		// insert a "no results" message
+		gchar* pszBuffer = g_strdup_printf("<span size='small'><i>Your search did not match any\nstreets or Points of Interest.</i></span>", pszSearch);
+		GtkTreeIter iter;
+		gtk_list_store_append(g_SearchWindow.m_pResultsListStore, &iter);
+		gtk_list_store_set(g_SearchWindow.m_pResultsListStore, &iter, 
+				   RESULTLIST_COLUMN_NAME, pszBuffer, 
+				   RESULTLIST_CLICKABLE, FALSE,
+				   -1);
+		g_free(pszBuffer);
+	}
+
 	// ensure the search results are visible
 	mainwindow_sidebar_set_tab(SIDEBAR_TAB_SEARCH_RESULTS);
 	mainwindow_set_sidebox_visible(TRUE);
@@ -130,30 +146,34 @@
 		RESULTLIST_LONGITUDE, pPoint->m_fLongitude,
 		RESULTLIST_DISTANCE, fDistance,
 		RESULTLIST_ZOOMLEVEL, nZoomLevel,
+		RESULTLIST_CLICKABLE, TRUE,
 		-1);
 
 	g_free(pszBuffer);
+
+	g_SearchWindow.m_nNumResults++;
 }
 
 static void searchwindow_go_to_selected_result(void)
 {
-	GtkTreeSelection* pSelection = gtk_tree_view_get_selection(
-		g_SearchWindow.m_pResultsTreeView);
+	GtkTreeSelection* pSelection = gtk_tree_view_get_selection(g_SearchWindow.m_pResultsTreeView);
 
 	GtkTreeIter iter;
 	GtkTreeModel* pModel = GTK_TREE_MODEL(g_SearchWindow.m_pResultsListStore);
 	if(gtk_tree_selection_get_selected(pSelection, &pModel, &iter)) {
 		mappoint_t pt;
 		gint nZoomLevel;
+		gboolean bClickable;
 		gtk_tree_model_get(GTK_TREE_MODEL(g_SearchWindow.m_pResultsListStore), &iter,
 			RESULTLIST_LATITUDE, &pt.m_fLatitude,
 			RESULTLIST_LONGITUDE, &pt.m_fLongitude,
 			RESULTLIST_ZOOMLEVEL, &nZoomLevel,
+			RESULTLIST_CLICKABLE, &bClickable,
 			-1);
 
+		if(!bClickable) return;	// XXX: is this the right way to make a treeview item not clickable?
+
 		mainwindow_map_slide_to_mappoint(&pt);
-//		mainwindow_map_center_on_mappoint(&pt);
-		//mainwindow_statusbar_update_position();
 		mainwindow_set_zoomlevel(nZoomLevel);
 		mainwindow_draw_map(DRAWFLAG_ALL);
 	}
@@ -166,6 +186,6 @@
 
 static void searchwindow_on_resultslist_selection_changed(GtkTreeSelection *treeselection, gpointer user_data)
 {
-	GTK_PROCESS_MAINLOOP;
+	GTK_PROCESS_MAINLOOP;	// make sure GUI updates before we start our cpu-intensive move to the result
 	searchwindow_go_to_selected_result();
 }




More information about the cairo-commit mailing list