[cairo-commit] roadster/src downloadmanager.c, 1.1, 1.2 mainwindow.c, 1.47, 1.48 mainwindow.h, 1.12, 1.13 map_history.c, 1.1, 1.2 searchwindow.c, 1.25, 1.26 util.c, 1.14, 1.15 util.h, 1.14, 1.15

Ian McIntosh commit at pdx.freedesktop.org
Sat Oct 1 12:09:07 PDT 2005


Committed by: ian

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

Modified Files:
	downloadmanager.c mainwindow.c mainwindow.h map_history.c 
	searchwindow.c util.c util.h 
Log Message:
	* src/downloadmanager.c: Remove _ from public function _downloadmanager_new().
	* src/mainwindow.c: Set check on View/Fullscreen and View/Sidebar when state changes for reasons other than the user clicking the menu item.
	* src/map_history.c: Add some debug printing support.
	* src/searchwindow.c: Add a new history item when user selects a search result.
	* src/util.c: Moved some basic window state set/test functions here.


Index: downloadmanager.c
===================================================================
RCS file: /cvs/cairo/roadster/src/downloadmanager.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- downloadmanager.c	1 Oct 2005 05:24:16 -0000	1.1
+++ downloadmanager.c	1 Oct 2005 19:09:05 -0000	1.2
@@ -38,7 +38,7 @@
 typedef struct {
 	gchar* pszRemoteFilePath;
 	gchar* pszLocalFilePath;								// will be NULL until file moves into 'active' list
-	gint nBytesDownloaded;								// a count
+	gint nBytesDownloaded;									// a count
 
 	downloadmanager_t* pDownloadManager;					// a handy pointer to the parent
 	GnomeVFSAsyncHandle* pGnomeVFSHandle;
@@ -52,9 +52,9 @@
 static void _downloadmanager_move_pending_to_active(downloadmanager_t* pDownloadManager);
 
 //
-// functions
+// Public API
 //
-downloadmanager_t* _downloadmanager_new(gint nMaxConcurrentActive)
+downloadmanager_t* downloadmanager_new(gint nMaxConcurrentActive)
 {
 	downloadmanager_t* pNew = g_new0(downloadmanager_t, 1);
 	pNew->pActiveArray = g_ptr_array_new();
@@ -78,9 +78,13 @@
 	_downloadmanager_move_pending_to_active(pDownloadManager);
 }
 
-// Check to see if we can add any pending files to active list
+//
+// Private functions
+//
+
 static void _downloadmanager_move_pending_to_active(downloadmanager_t* pDownloadManager)
 {
+	// Check to see if we can add any pending files to active list
 	if((pDownloadManager->pActiveArray->len < pDownloadManager->nMaxConcurrentActive) && (pDownloadManager->pPendingArray->len > 0)) {
 		// time to promote one from pending
 		download_t* pNext = g_ptr_array_index(pDownloadManager->pPendingArray, 0);

Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- mainwindow.c	1 Oct 2005 05:24:16 -0000	1.47
+++ mainwindow.c	1 Oct 2005 19:09:05 -0000	1.48
@@ -125,9 +125,14 @@
 // Prototypes
 static void mainwindow_setup_selected_tool(void);
 static void mainwindow_map_center_on_windowpoint(gint nX, gint nY);
-static void mainwindow_add_history();
 static void mainwindow_on_web_url_clicked(GtkWidget *_unused, gchar* pszURLPattern);
 
+static gboolean mainwindow_on_window_state_change(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+
+void mainwindow_update_zoom_buttons();
+
+void mainwindow_on_sidebarmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
+
 static gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event);
 static gboolean mainwindow_on_mouse_motion(GtkWidget* w, GdkEventMotion *event);
 static gboolean mainwindow_on_mouse_scroll(GtkWidget* w, GdkEventScroll *event);
@@ -139,6 +144,9 @@
 static gboolean mainwindow_on_leave_notify(GtkWidget* w, GdkEventCrossing *event);
 static void 	mainwindow_on_locationset_visible_checkbox_clicked(GtkCellRendererToggle *cell, gchar *path_str, gpointer data);
 static gboolean mainwindow_on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+static gboolean mainwindow_on_key_release(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+
+void mainwindow_on_fullscreenmenuitem_activate(GtkMenuItem *menuitem, gpointer user_data);
 
 static void mainwindow_configure_locationset_list();
 void mainwindow_refresh_locationset_list();
@@ -236,6 +244,9 @@
 	GtkMenuItem* pBackMenuItem;
 	
 	GtkMenuItem* pWebMapsMenuItem;
+
+	GtkCheckMenuItem* pViewSidebarMenuItem;
+	GtkCheckMenuItem* pViewFullscreenMenuItem;
 } g_MainWindow = {0};
 
 // XXX: Use GDK_HAND1 for the map
@@ -354,6 +365,10 @@
 	GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pSidebarNotebook, GTK_NOTEBOOK, "sidebarnotebook");
 	GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pContentBox, GTK_VBOX, "mainwindowcontentsbox");
 
+	// View menu
+   	GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pViewSidebarMenuItem, GTK_CHECK_MENU_ITEM, "viewsidebarmenuitem");
+   	GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pViewFullscreenMenuItem, GTK_CHECK_MENU_ITEM, "viewfullscreenmenuitem");
+
 	// Zoom controls
 	GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pZoomInButton, GTK_BUTTON, "zoominbutton");
 	GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pZoomInMenuItem, GTK_MENU_ITEM, "zoominmenuitem");
@@ -399,22 +414,38 @@
 	g_MainWindow.pTooltips		= gtk_tooltips_new();
 	g_MainWindow.pTooltip 		= tooltip_new();
 
-	// Drawing area
-	g_MainWindow.pDrawingArea = GTK_DRAWING_AREA(gtk_drawing_area_new());	
-	gtk_widget_show(GTK_WIDGET(g_MainWindow.pDrawingArea));
 
-	// create map and load style
-	map_new(&g_MainWindow.pMap, GTK_WIDGET(g_MainWindow.pDrawingArea));
-	map_style_load(g_MainWindow.pMap, MAP_STYLE_FILENAME);
+	// Signal handlers for main window
+	gtk_widget_add_events(GTK_WIDGET(g_MainWindow.pWindow), GDK_KEY_PRESS_MASK);
+	g_signal_connect(G_OBJECT(g_MainWindow.pWindow), "window_state_event", G_CALLBACK(mainwindow_on_window_state_change), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pWindow), "key_press_event", G_CALLBACK(mainwindow_on_key_press), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pWindow), "key_release_event", G_CALLBACK(mainwindow_on_key_release), NULL);
 	
-	g_assert(g_MainWindow.pContentBox);
-	g_assert(g_MainWindow.pDrawingArea);
+	// Drawing area
+	g_MainWindow.pDrawingArea = GTK_DRAWING_AREA(gtk_drawing_area_new());	
 
 	// Pack drawing area into application window
 	gtk_box_pack_end(GTK_BOX(g_MainWindow.pContentBox), GTK_WIDGET(g_MainWindow.pDrawingArea),
 					TRUE, // expand
 					TRUE, // fill
 					 0);
+	gtk_widget_show(GTK_WIDGET(g_MainWindow.pDrawingArea));
+	
+	// Signal handlers for drawing area
+	gtk_widget_add_events(GTK_WIDGET(g_MainWindow.pDrawingArea), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "expose_event", G_CALLBACK(mainwindow_on_expose_event), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "configure_event", G_CALLBACK(mainwindow_on_configure_event), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "button_press_event", G_CALLBACK(mainwindow_on_mouse_button_click), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "button_release_event", G_CALLBACK(mainwindow_on_mouse_button_click), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "motion_notify_event", G_CALLBACK(mainwindow_on_mouse_motion), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "scroll_event", G_CALLBACK(mainwindow_on_mouse_scroll), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "enter_notify_event", G_CALLBACK(mainwindow_on_enter_notify), NULL);
+	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "leave_notify_event", G_CALLBACK(mainwindow_on_leave_notify), NULL);
+
+	// create map and load style
+	map_new(&g_MainWindow.pMap, GTK_WIDGET(g_MainWindow.pDrawingArea));
+	map_style_load(g_MainWindow.pMap, MAP_STYLE_FILENAME);
+	
 
 	cursor_init();
 
@@ -434,17 +465,9 @@
 	// When main window closes, quit.
 	g_signal_connect(G_OBJECT(g_MainWindow.pWindow), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
 
-	// Signal handlers for drawing area
-	gtk_widget_add_events(GTK_WIDGET(g_MainWindow.pDrawingArea), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "expose_event", G_CALLBACK(mainwindow_on_expose_event), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "configure_event", G_CALLBACK(mainwindow_on_configure_event), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "button_press_event", G_CALLBACK(mainwindow_on_mouse_button_click), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "button_release_event", G_CALLBACK(mainwindow_on_mouse_button_click), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "motion_notify_event", G_CALLBACK(mainwindow_on_mouse_motion), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "scroll_event", G_CALLBACK(mainwindow_on_mouse_scroll), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "enter_notify_event", G_CALLBACK(mainwindow_on_enter_notify), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "leave_notify_event", G_CALLBACK(mainwindow_on_leave_notify), NULL);
-	g_signal_connect(G_OBJECT(g_MainWindow.pDrawingArea), "key_press_event", G_CALLBACK(mainwindow_on_key_press), NULL);
+	// XXX: move map to starting location... for now it's (0,0)
+	mainwindow_add_history();
+	mainwindow_update_zoom_buttons();	// make sure buttons are grayed out
 }
 
 gboolean mainwindow_locationset_list_is_separator_callback(GtkTreeModel *_unused, GtkTreeIter *pIter, gpointer __unused)
@@ -669,12 +692,12 @@
 */
 void mainwindow_set_sidebox_visible(gboolean bVisible)
 {
-	if(bVisible) {
-		gtk_widget_show(GTK_WIDGET(g_MainWindow.pSidebox));
-	}
-	else {
-		gtk_widget_hide(GTK_WIDGET(g_MainWindow.pSidebox));
-	}
+	// Set the menu's check without calling the signal handler
+	g_signal_handlers_block_by_func(g_MainWindow.pViewSidebarMenuItem, mainwindow_on_sidebarmenuitem_activate, NULL);
+	gtk_check_menu_item_set_active(g_MainWindow.pViewSidebarMenuItem, bVisible);
+	g_signal_handlers_unblock_by_func(g_MainWindow.pViewSidebarMenuItem, mainwindow_on_sidebarmenuitem_activate, NULL);
+
+	util_gtk_widget_set_visible(GTK_WIDGET(g_MainWindow.pSidebox), bVisible);
 }
 
 gboolean mainwindow_get_sidebox_visible(void)
@@ -689,16 +712,7 @@
 
 void mainwindow_toggle_fullscreen(void)
 {
-    GdkWindow* pTopLevelGDKWindow = gdk_window_get_toplevel(GTK_WIDGET(g_MainWindow.pWindow)->window);
-	g_return_if_fail(pTopLevelGDKWindow != NULL);
-
-	GdkWindowState windowstate = gdk_window_get_state(pTopLevelGDKWindow);
-	if(windowstate & GDK_WINDOW_STATE_FULLSCREEN) {
-		gdk_window_unfullscreen(pTopLevelGDKWindow);
-	}
-	else {
-		gdk_window_fullscreen(pTopLevelGDKWindow);
-	}
+	util_gtk_window_set_fullscreen(g_MainWindow.pWindow, !util_gtk_window_is_fullscreen(g_MainWindow.pWindow));
 }
 
 // User clicked Quit window
@@ -730,7 +744,7 @@
 	map_set_zoomlevel(g_MainWindow.pMap, nZoomLevel);
 
 	// set zoomlevel scale but prevent it from calling handler (mainwindow_on_zoomscale_value_changed)
-        g_signal_handlers_block_by_func(g_MainWindow.pZoomScale, mainwindow_on_zoomscale_value_changed, NULL);
+    g_signal_handlers_block_by_func(g_MainWindow.pZoomScale, mainwindow_on_zoomscale_value_changed, NULL);
 	gtk_range_set_value(GTK_RANGE(g_MainWindow.pZoomScale), nZoomLevel);
 	g_signal_handlers_unblock_by_func(g_MainWindow.pZoomScale, mainwindow_on_zoomscale_value_changed, NULL);
 
@@ -850,6 +864,8 @@
 {
 	// tell the map
 	map_set_zoomlevel(g_MainWindow.pMap, map_get_zoomlevel(g_MainWindow.pMap) + 1);
+	
+	// update the gui
 	mainwindow_set_zoomlevel(map_get_zoomlevel(g_MainWindow.pMap));
 	mainwindow_draw_map(DRAWFLAG_GEOMETRY);
 	mainwindow_set_draw_pretty_timeout(DRAW_PRETTY_ZOOM_TIMEOUT_MS);
@@ -1280,6 +1296,20 @@
 static gboolean mainwindow_on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 {
 	g_print("key_press\n");
+	return FALSE;
+}
+static gboolean mainwindow_on_key_release(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+	g_print("key_release\n");
+	return FALSE;
+}
+
+static gboolean mainwindow_on_window_state_change(GtkWidget *_unused, GdkEventKey *pEvent, gpointer __unused)
+{
+	// Set the menu's check without calling the signal handler
+	g_signal_handlers_block_by_func(g_MainWindow.pViewFullscreenMenuItem, mainwindow_on_fullscreenmenuitem_activate, NULL);
+	gtk_check_menu_item_set_active(g_MainWindow.pViewFullscreenMenuItem, util_gtk_window_is_fullscreen(g_MainWindow.pWindow));
+	g_signal_handlers_unblock_by_func(g_MainWindow.pViewFullscreenMenuItem, mainwindow_on_fullscreenmenuitem_activate, NULL);
 }
 
 static void mainwindow_begin_import_geography_data(void)
@@ -1662,7 +1692,7 @@
 	mainwindow_update_forward_back_buttons();
 }
 
-static void mainwindow_add_history()
+void mainwindow_add_history()
 {
 	// add the current spot to the history
 	mappoint_t point;

Index: mainwindow.h
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mainwindow.h	30 Sep 2005 05:09:51 -0000	1.12
+++ mainwindow.h	1 Oct 2005 19:09:05 -0000	1.13
@@ -74,6 +74,8 @@
 void mainwindow_map_get_centerpoint(mappoint_t* pPoint);
 void mainwindow_map_slide_to_mappoint(mappoint_t* pPoint);
 
+void mainwindow_add_history();
+
 typedef enum {
 	DIRECTION_NONE, DIRECTION_N, DIRECTION_NE, DIRECTION_E, DIRECTION_SE, DIRECTION_S, DIRECTION_SW, DIRECTION_W, DIRECTION_NW
 } EDirection;

Index: map_history.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_history.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- map_history.c	1 Oct 2005 05:24:16 -0000	1.1
+++ map_history.c	1 Oct 2005 19:09:05 -0000	1.2
@@ -26,6 +26,8 @@
 #include "map.h"
 #include "map_history.h"
 
+static void map_history_debug_print(maphistory_t* pHistory);
+
 typedef struct {
 	mappoint_t MapPoint;
 	gint nZoomLevel;
@@ -72,6 +74,7 @@
 	pHistory->nTotalItems++;
 
 	g_assert(pHistory->nCurrentIndex < pHistory->nTotalItems);
+	map_history_debug_print(pHistory);
 }
 
 gboolean map_history_can_go_forward(maphistory_t* pHistory)
@@ -88,6 +91,7 @@
 {
 	if(map_history_can_go_forward(pHistory)) {
 		pHistory->nCurrentIndex++;
+		map_history_debug_print(pHistory);
 		return TRUE;
 	}
 }
@@ -96,6 +100,7 @@
 {
 	if(map_history_can_go_back(pHistory)) {
 		pHistory->nCurrentIndex--;
+		map_history_debug_print(pHistory);
 		return TRUE;
 	}
 }
@@ -113,3 +118,16 @@
 	memcpy(pReturnPoint, &(pCurrent->MapPoint), sizeof(mappoint_t));
 	*pnReturnZoomLevel  = pCurrent->nZoomLevel;
 }
+
+static void map_history_debug_print(maphistory_t* pHistory)
+{
+	return;
+
+	gint i;
+	g_print("Map History:\n");
+	for(i=0 ; i<pHistory->nTotalItems ; i++) {
+		mapview_t* pCurrent = &g_array_index(pHistory->MapViewArray, mapview_t, i);
+
+		g_print("%s(%f,%f @ %d)\n", (i==pHistory->nCurrentIndex) ? "*" : "", pCurrent->MapPoint.fLongitude, pCurrent->MapPoint.fLatitude, pCurrent->nZoomLevel);
+	}
+}

Index: searchwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/searchwindow.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- searchwindow.c	30 Sep 2005 05:09:51 -0000	1.25
+++ searchwindow.c	1 Oct 2005 19:09:05 -0000	1.26
@@ -305,6 +305,7 @@
 		//mainwindow_map_slide_to_mappoint(&pt);
 		mainwindow_set_zoomlevel(nZoomLevel);
 		mainwindow_map_center_on_mappoint(&pt);
+		mainwindow_add_history();
 
 		void* pBusy = mainwindow_set_busy();
 		mainwindow_draw_map(DRAWFLAG_ALL);

Index: util.c
===================================================================
RCS file: /cvs/cairo/roadster/src/util.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- util.c	1 Oct 2005 05:24:16 -0000	1.14
+++ util.c	1 Oct 2005 19:09:05 -0000	1.15
@@ -404,6 +404,28 @@
 	return pszReturn;
 }
 
+gboolean util_gtk_window_is_fullscreen(GtkWindow* pWindow)
+{
+    GdkWindow* pTopLevelGDKWindow = gdk_window_get_toplevel(GTK_WIDGET(pWindow)->window);
+	g_return_if_fail(pTopLevelGDKWindow != NULL);
+
+	GdkWindowState windowstate = gdk_window_get_state(pTopLevelGDKWindow);
+
+	return((windowstate & GDK_WINDOW_STATE_FULLSCREEN) > 0);
+}
+
+gboolean util_gtk_window_set_fullscreen(GtkWindow* pWindow, gboolean bFullscreen)
+{
+	GdkWindow* pTopLevelGDKWindow = gdk_window_get_toplevel(GTK_WIDGET(pWindow)->window);
+	g_return_if_fail(pTopLevelGDKWindow != NULL);
+	if(bFullscreen) {
+		gdk_window_fullscreen(pTopLevelGDKWindow);
+	}
+	else {
+		gdk_window_unfullscreen(pTopLevelGDKWindow);
+	}
+}
+
 //
 // 
 //
@@ -448,3 +470,5 @@
 	// Init it
 	_util_gtk_entry_on_focus_out_event(pEntry, NULL, pszHint);
 }
+
+

Index: util.h
===================================================================
RCS file: /cvs/cairo/roadster/src/util.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- util.h	1 Oct 2005 05:24:16 -0000	1.14
+++ util.h	1 Oct 2005 19:09:05 -0000	1.15
@@ -58,6 +58,9 @@
 gboolean util_gtk_tree_view_select_next(GtkTreeView* pTreeView);
 gboolean util_gtk_tree_view_select_previous(GtkTreeView* pTreeView);
 
+gboolean util_gtk_window_is_fullscreen(GtkWindow* pWindow);
+gboolean util_gtk_window_set_fullscreen(GtkWindow* pWindow, gboolean bFullscreen);
+
 // if glib < 2.6
 #if(!GLIB_CHECK_VERSION(2,6,0))
 gint g_strv_length(const gchar** a);



More information about the cairo-commit mailing list