[cairo-commit] roadster/src Makefile.am, 1.22, 1.23 downloader.c,
1.2, NONE downloader.h, 1.2, NONE downloadmanager.c, NONE,
1.1 downloadmanager.h, NONE, 1.1 glyph.c, 1.9, 1.10 glyph.h,
1.6, 1.7 gui.c, 1.14, 1.15 history.c, 1.4, NONE history.h, 1.2,
NONE main.c, 1.31, 1.32 mainwindow.c, 1.46, 1.47 map.c, 1.50,
1.51 map_draw_cairo.c, 1.26, 1.27 map_draw_gdk.c, 1.24,
1.25 map_history.c, NONE, 1.1 map_history.h, NONE,
1.1 map_style.c, 1.3, 1.4 tooltip.c, 1.6, NONE tooltip.h, 1.4,
NONE util.c, 1.13, 1.14 util.h, 1.13, 1.14 welcomewindow.c,
1.8, NONE welcomewindow.h, 1.2, NONE
Ian McIntosh
commit at pdx.freedesktop.org
Fri Sep 30 22:24:18 PDT 2005
Committed by: ian
Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv12277/src
Modified Files:
Makefile.am glyph.c glyph.h gui.c main.c mainwindow.c map.c
map_draw_cairo.c map_draw_gdk.c map_style.c util.c util.h
Added Files:
downloadmanager.c downloadmanager.h map_history.c
map_history.h
Removed Files:
downloader.c downloader.h history.c history.h tooltip.c
tooltip.h welcomewindow.c welcomewindow.h
Log Message:
* Renamed src/history.c to src/map_history.c
* Renamed src/tooltip.c to src/tooltipwindow.c
* Renamed src/downloader.c to src/downloadmanager.c
* src/glyph.c: Only require a targetwidget when generating a pixmap.
* src/main.c: Move glyph module init here.
* src/*: Fix all compiler warning messages.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/roadster/src/Makefile.am,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- Makefile.am 1 Oct 2005 01:42:12 -0000 1.22
+++ Makefile.am 1 Oct 2005 05:24:16 -0000 1.23
@@ -20,12 +20,13 @@
roadster_SOURCES = \
main.c\
db.c\
- downloader.c\
+ downloadmanager.c\
gui.c\
mainwindow.c\
gotowindow.c\
map.c\
map_tile.c\
+ map_history.c\
map_style.c\
map_draw_cairo.c\
map_draw_gdk.c\
@@ -47,8 +48,7 @@
road.c\
animator.c\
gfreelist.c\
- history.c\
- tooltip.c
+ tooltipwindow.c
roadster_LDADD = \
$(GNOME_LIBS) \
--- downloader.c DELETED ---
--- downloader.h DELETED ---
--- NEW FILE: downloadmanager.c ---
/***************************************************************************
* downloader.c
*
* Copyright 2005 Ian McIntosh
* ian_mcintosh at linuxadvocate.org
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Purpose:
// A general purpose, easy to use, asyncronous download manager. Hand it URLs,
// and it calls your callback function when it's done. It's that simple!
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libgnomevfs/gnome-vfs.h>
#include <gnome.h>
#include "downloadmanager.h"
#define TEMP_FILE_TEMPLATE ("roadster_download_XXXXXX") // format of temp files
typedef struct {
gchar* pszRemoteFilePath;
gchar* pszLocalFilePath; // will be NULL until file moves into 'active' list
gint nBytesDownloaded; // a count
downloadmanager_t* pDownloadManager; // a handy pointer to the parent
GnomeVFSAsyncHandle* pGnomeVFSHandle;
DownloadManagerCallbackFileResult pCallbackFileResult; // called when file succeeds or fails
} download_t;
//
// prototypes
//
static gboolean _downloadmanager_begin_download(download_t* pDownload);
static void _downloadmanager_move_pending_to_active(downloadmanager_t* pDownloadManager);
//
// functions
//
downloadmanager_t* _downloadmanager_new(gint nMaxConcurrentActive)
{
downloadmanager_t* pNew = g_new0(downloadmanager_t, 1);
pNew->pActiveArray = g_ptr_array_new();
pNew->pPendingArray = g_ptr_array_new();
pNew->nMaxConcurrentActive = nMaxConcurrentActive;
return pNew;
}
void downloadmanager_add_uri(downloadmanager_t* pDownloadManager, const gchar* pszRemoteFilePath, DownloadManagerCallbackFileResult pCallbackFileResult)
{
g_assert(pDownloadManager != NULL);
g_assert(pszRemoteFilePath != NULL);
g_assert(pCallbackFileResult != NULL);
download_t* pNewDownload = g_new0(download_t, 1);
pNewDownload->pszRemoteFilePath = g_strdup(pszRemoteFilePath);
pNewDownload->pCallbackFileResult = pCallbackFileResult;
pNewDownload->pDownloadManager = pDownloadManager;
g_ptr_array_add(pDownloadManager->pPendingArray, pNewDownload);
_downloadmanager_move_pending_to_active(pDownloadManager);
}
// Check to see if we can add any pending files to active list
static void _downloadmanager_move_pending_to_active(downloadmanager_t* pDownloadManager)
{
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);
if(_downloadmanager_begin_download(pNext)) {
g_ptr_array_remove(pDownloadManager->pPendingArray, pNext);
g_ptr_array_add(pDownloadManager->pActiveArray, pNext);
}
}
}
// static void _downloader_gnome_vfs_close_callback(GnomeVFSAsyncHandle *_unused, GnomeVFSResult __unused, gpointer ___unused)
// {
// //g_print("downloader: a file has been closed\n");
// }
static void _downloadmanager_download_free(downloadmanager_t* pDownloadManager, download_t* pDownload)
{
// Empty struct
g_free(pDownload->pszRemoteFilePath);
g_free(pDownload->pszLocalFilePath);
if(pDownload->pGnomeVFSHandle != NULL) {
// XXX: do we need to close this?
// gnome_vfs_async_close(pDownload->pGnomeVFSHandle, _downloader_gnome_vfs_close_callback, NULL);
}
// XXX: store a 'state' so we know which array it's in?
g_ptr_array_remove_fast(pDownloadManager->pActiveArray, pDownload);
g_ptr_array_remove(pDownloadManager->pPendingArray, pDownload);
// Free struct
g_free(pDownload);
}
static gint _downloadmanager_gnome_vfs_progress_callback(GnomeVFSAsyncHandle *pHandle, GnomeVFSXferProgressInfo *pInfo, download_t* pDownload)
{
g_assert(pHandle != NULL);
g_assert(pInfo != NULL);
g_assert(pDownload != NULL);
pDownload->nBytesDownloaded = pInfo->bytes_copied;
if(pInfo->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
g_print("downloader: downloaded '%s' to '%s' (%d bytes)\n", pDownload->pszRemoteFilePath, pDownload->pszLocalFilePath, pDownload->nBytesDownloaded);
// Call user-supplied callback
pDownload->pCallbackFileResult(pDownload->pszRemoteFilePath, DOWNLOADMANAGER_RESULT_SUCCESS, pDownload->pszLocalFilePath);
// callback shouldn't leave the file in the temp directory
if(g_file_test(pDownload->pszLocalFilePath, G_FILE_TEST_EXISTS)) {
g_warning("downloader: callback failed to move/delete local file '%s' (from remote '%s')\n", pDownload->pszLocalFilePath, pDownload->pszRemoteFilePath);
}
downloadmanager_t* pDownloadManager = pDownload->pDownloadManager;
_downloadmanager_download_free(pDownloadManager, pDownload);
//
_downloadmanager_move_pending_to_active(pDownloadManager);
}
// XXX: what other statuses messages do we care about? (failed?)
}
static gboolean _downloadmanager_begin_download(download_t* pDownload)
{
g_assert(pDownload != NULL);
//g_print("downloader: beginning download of %s\n", pDownload->pszRemoteFilePath);
g_assert(pDownload->pszLocalFilePath == NULL);
gint nHandle = g_file_open_tmp(TEMP_FILE_TEMPLATE, &(pDownload->pszLocalFilePath), NULL);
if(nHandle == -1) {
g_warning("downloader: failed to create a temporary file\n");
return FALSE;
}
g_assert(pDownload->pszLocalFilePath != NULL);
close(nHandle); // we don't use the file here. gnome-vfs overwrites it.
//g_print("downloader: using temp file '%s'\n", pDownload->pszLocalFilePath);
GnomeVFSURI* pSrcURI = gnome_vfs_uri_new(pDownload->pszRemoteFilePath);
GList* pSrcList = g_list_prepend(pSrcList, pSrcURI);
GnomeVFSURI* pDestURI = gnome_vfs_uri_new(pDownload->pszLocalFilePath);
GList* pDestList = g_list_prepend(pDestList, pDestURI);
GnomeVFSResult res = gnome_vfs_async_xfer(&(pDownload->pGnomeVFSHandle),
pSrcList, pDestList,
GNOME_VFS_XFER_DEFAULT,
GNOME_VFS_XFER_ERROR_MODE_ABORT,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, // overwrite the tmp file we just made.
GNOME_VFS_PRIORITY_MIN,
(GnomeVFSAsyncXferProgressCallback)_downloadmanager_gnome_vfs_progress_callback,
(gpointer)pDownload, // callback userdata
NULL,
NULL);
gnome_vfs_uri_unref(pSrcURI);
gnome_vfs_uri_unref(pDestURI);
g_list_free(pSrcList);
g_list_free(pDestList);
if(res != GNOME_VFS_OK) {
// return the download_t to a 'pending' state
g_free(pDownload->pszLocalFilePath); pDownload->pszLocalFilePath = NULL;
g_assert(pDownload->pGnomeVFSHandle == NULL);
return FALSE;
}
g_assert(pDownload->pGnomeVFSHandle != NULL);
return TRUE;
}
--- NEW FILE: downloadmanager.h ---
/***************************************************************************
* downloader.h
*
* Copyright 2005 Ian McIntosh
* ian_mcintosh at linuxadvocate.org
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _DOWNLOADMANAGER_H_
#define _DOWNLOADMANAGER_H_
#include <libgnomevfs/gnome-vfs.h>
#include <gtk/gtk.h>
typedef enum { DOWNLOADMANAGER_RESULT_FAILURE=0, DOWNLOADMANAGER_RESULT_SUCCESS } EDownloadManagerFileResult;
typedef void (*DownloadManagerCallbackFileResult)(const gchar* pszRemotePath, EDownloadManagerFileResult eDownloadManagerResult, const gchar* pszLocalPath);
typedef struct {
GPtrArray* pPendingArray;
GPtrArray* pActiveArray;
gint nMaxConcurrentActive;
} downloadmanager_t;
// public API
downloadmanager_t* downloadmanager_new(gint nMaxConcurrentActive);
void downloadmanager_add_uri(downloadmanager_t* pDownloader, const gchar* pszRemoteFilePath, DownloadManagerCallbackFileResult pCallbackFileResult);
#endif
Index: glyph.c
===================================================================
RCS file: /cvs/cairo/roadster/src/glyph.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- glyph.c 30 Sep 2005 05:09:51 -0000 1.9
+++ glyph.c 1 Oct 2005 05:24:16 -0000 1.10
@@ -28,12 +28,10 @@
struct {
GPtrArray* pGlyphArray; // to store all glyphs we hand out
- GtkWidget* pTargetWidget;
} g_Glyph = {0};
-void glyph_init(GtkWidget* pTargetWidget)
+void glyph_init()
{
- g_Glyph.pTargetWidget = pTargetWidget;
g_Glyph.pGlyphArray = g_ptr_array_new();
}
@@ -139,7 +137,6 @@
// Load at image's default size
glyph_t* glyph_load(const gchar* pszName)
{
- g_assert(g_Glyph.pTargetWidget != NULL);
g_assert(g_Glyph.pGlyphArray != NULL);
g_assert(pszName != NULL);
@@ -168,7 +165,6 @@
glyph_t* glyph_load_at_size(const gchar* pszName, gint nMaxWidth, gint nMaxHeight)
{
- g_assert(g_Glyph.pTargetWidget != NULL);
g_assert(g_Glyph.pGlyphArray != NULL);
g_assert(pszName != NULL);
@@ -206,14 +202,15 @@
return pGlyph->pPixbuf;
}
-GdkPixmap* glyph_get_pixmap(glyph_t* pGlyph)
+GdkPixmap* glyph_get_pixmap(glyph_t* pGlyph, GtkWidget* pTargetWidget)
{
g_assert(pGlyph != NULL);
-
+
if(pGlyph->pPixmap == NULL) {
- GdkGC* pGC = g_Glyph.pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(g_Glyph.pTargetWidget)];
- pGlyph->pPixmap = gdk_pixmap_new(g_Glyph.pTargetWidget->window, pGlyph->nWidth, pGlyph->nHeight, -1); // -1 is bpp
- gdk_draw_pixbuf(pGlyph->pPixmap, pGC, pGlyph->pPixbuf,0,0,0,0,-1,-1,
+ // XXX: This assumes that we aren't being passed different pTargetWidgets each time
+ pGlyph->pPixmap = gdk_pixmap_new(pTargetWidget->window, pGlyph->nWidth, pGlyph->nHeight, -1); // -1 is bpp
+ GdkGC* pGC = pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pTargetWidget)];
+ gdk_draw_pixbuf(pGlyph->pPixmap, pGC, pGlyph->pPixbuf, 0,0,0,0,-1,-1,
GDK_RGB_DITHER_NONE,0,0); // no dithering
}
g_assert(pGlyph->pPixmap != NULL);
Index: glyph.h
===================================================================
RCS file: /cvs/cairo/roadster/src/glyph.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- glyph.h 30 Sep 2005 05:09:51 -0000 1.6
+++ glyph.h 1 Oct 2005 05:24:16 -0000 1.7
@@ -38,10 +38,11 @@
gint nReferenceCount;
} glyph_t;
-void glyph_init(GtkWidget* pTargetWidget);
+void glyph_init();
glyph_t* glyph_load_at_size(const gchar* pszName, gint nMaxWidth, gint nMaxHeight);
+glyph_t* glyph_load(const gchar* pszName);
GdkPixbuf* glyph_get_pixbuf(const glyph_t* pGlyph);
-GdkPixmap* glyph_get_pixmap(glyph_t* pGlyph);
+GdkPixmap* glyph_get_pixmap(glyph_t* pGlyph, GtkWidget* pTargetWidget);
//void glyph_draw_centered(cairo_t* pCairo, gint nGlyphHandle, gdouble fX, gdouble fY);
void glyph_draw_centered(glyph_t* pGlyph, GdkDrawable* pTargetDrawable, GdkGC* pGC, gdouble fX, gdouble fY);
void glyph_deinit(void);
Index: gui.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gui.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gui.c 1 Oct 2005 01:42:12 -0000 1.14
+++ gui.c 1 Oct 2005 05:24:16 -0000 1.15
@@ -37,7 +37,7 @@
#include "searchwindow.h"
#include "locationeditwindow.h"
-void gui_init()
+void gui_init(void)
{
GladeXML* pGladeXML = gui_load_xml(GLADE_FILE_NAME, NULL);
glade_xml_signal_autoconnect(pGladeXML);
--- history.c DELETED ---
--- history.h DELETED ---
Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- main.c 1 Oct 2005 01:42:12 -0000 1.31
+++ main.c 1 Oct 2005 05:24:16 -0000 1.32
@@ -162,6 +162,9 @@
main_debug_insert_test_data();
+ g_print("initializing glyphs\n");
+ glyph_init();
+
//
// Load location sets from DB. This is "coffee shops", "ATMs", etc.
//
Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mainwindow.c 1 Oct 2005 01:42:12 -0000 1.46
+++ mainwindow.c 1 Oct 2005 05:24:16 -0000 1.47
@@ -46,8 +46,9 @@
#include "mainwindow.h"
#include "glyph.h"
#include "animator.h"
-#include "history.h"
-#include "tooltip.h"
+#include "map_history.h"
+
+#include "tooltipwindow.h"
#define PROGRAM_NAME "Roadster"
#define PROGRAM_COPYRIGHT "Copyright (c) 2005 Ian McIntosh"
@@ -125,7 +126,7 @@
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, gpointer* pszURLPattern);
+static void mainwindow_on_web_url_clicked(GtkWidget *_unused, gchar* pszURLPattern);
static gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event);
static gboolean mainwindow_on_mouse_motion(GtkWidget* w, GdkEventMotion *event);
@@ -198,7 +199,7 @@
GtkProgressBar* pProgressBar;
// Boxes
- GtkHBox* pContentBox;
+ GtkVBox* pContentBox;
// Drawing area
GtkDrawingArea* pDrawingArea;
@@ -228,7 +229,7 @@
animator_t* pAnimator;
// History (forward / back)
- history_t* pHistory;
+ maphistory_t* pMapHistory;
GtkButton* pForwardButton;
GtkButton* pBackButton;
GtkMenuItem* pForwardMenuItem;
@@ -328,11 +329,11 @@
else {
pszName = g_strdup_printf("%s", aWebMapURLs[i].pszName);
}
- GtkMenuItem* pNewMenuItem = gtk_menu_item_new_with_mnemonic(pszName);
+ GtkMenuItem* pNewMenuItem = GTK_MENU_ITEM(gtk_menu_item_new_with_mnemonic(pszName));
g_free(pszName);
// Add a click handler which gets passed the URL with {TAGS}
- g_signal_connect(G_OBJECT(pNewMenuItem), "activate", mainwindow_on_web_url_clicked, aWebMapURLs[i].pszURL);
+ g_signal_connect(G_OBJECT(pNewMenuItem), "activate", (GCallback)mainwindow_on_web_url_clicked, aWebMapURLs[i].pszURL);
gtk_menu_shell_append(GTK_MENU_SHELL(pSubMenu), GTK_WIDGET(pNewMenuItem));
}
@@ -353,7 +354,6 @@
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pSidebarNotebook, GTK_NOTEBOOK, "sidebarnotebook");
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pContentBox, GTK_VBOX, "mainwindowcontentsbox");
-
// Zoom controls
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pZoomInButton, GTK_BUTTON, "zoominbutton");
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pZoomInMenuItem, GTK_MENU_ITEM, "zoominmenuitem");
@@ -386,7 +386,7 @@
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pBackButton, GTK_BUTTON, "backbutton");
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pForwardMenuItem, GTK_MENU_ITEM, "forwardmenuitem");
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pBackMenuItem, GTK_MENU_ITEM, "backmenuitem");
- g_MainWindow.pHistory = history_new();
+ g_MainWindow.pMapHistory = map_history_new();
// LocationSet Widgets
GLADE_LINK_WIDGET(pGladeXML, g_MainWindow.pLocationSetsTreeView, GTK_TREE_VIEW, "locationsetstreeview");
@@ -401,8 +401,6 @@
// Drawing area
g_MainWindow.pDrawingArea = GTK_DRAWING_AREA(gtk_drawing_area_new());
- g_print("initializing glyphs\n");
- glyph_init(g_MainWindow.pDrawingArea);
gtk_widget_show(GTK_WIDGET(g_MainWindow.pDrawingArea));
// create map and load style
@@ -1632,18 +1630,18 @@
//
void mainwindow_update_forward_back_buttons()
{
- gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pForwardButton), history_can_go_forward(g_MainWindow.pHistory));
- gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pBackButton), history_can_go_back(g_MainWindow.pHistory));
+ gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pForwardButton), map_history_can_go_forward(g_MainWindow.pMapHistory));
+ gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pBackButton), map_history_can_go_back(g_MainWindow.pMapHistory));
- gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pForwardMenuItem), history_can_go_forward(g_MainWindow.pHistory));
- gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pBackMenuItem), history_can_go_back(g_MainWindow.pHistory));
+ gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pForwardMenuItem), map_history_can_go_forward(g_MainWindow.pMapHistory));
+ gtk_widget_set_sensitive(GTK_WIDGET(g_MainWindow.pBackMenuItem), map_history_can_go_back(g_MainWindow.pMapHistory));
}
void mainwindow_go_to_current_history_item()
{
mappoint_t point;
gint nZoomLevel;
- history_get_current(g_MainWindow.pHistory, &point, &nZoomLevel);
+ map_history_get_current(g_MainWindow.pMapHistory, &point, &nZoomLevel);
mainwindow_set_zoomlevel(nZoomLevel);
mainwindow_map_center_on_mappoint(&point);
@@ -1652,14 +1650,14 @@
void mainwindow_on_backbutton_clicked(GtkWidget* _unused, gpointer* __unused)
{
- history_go_back(g_MainWindow.pHistory);
+ map_history_go_back(g_MainWindow.pMapHistory);
mainwindow_go_to_current_history_item();
mainwindow_update_forward_back_buttons();
}
void mainwindow_on_forwardbutton_clicked(GtkWidget* _unused, gpointer* __unused)
{
- history_go_forward(g_MainWindow.pHistory);
+ map_history_go_forward(g_MainWindow.pMapHistory);
mainwindow_go_to_current_history_item();
mainwindow_update_forward_back_buttons();
}
@@ -1670,7 +1668,7 @@
mappoint_t point;
map_get_centerpoint(g_MainWindow.pMap, &point);
- history_add(g_MainWindow.pHistory, &point, map_get_zoomlevel(g_MainWindow.pMap));
+ map_history_add(g_MainWindow.pMapHistory, &point, map_get_zoomlevel(g_MainWindow.pMap));
mainwindow_update_forward_back_buttons();
}
@@ -1732,7 +1730,7 @@
// }
}
-void mainwindow_on_web_url_clicked(GtkWidget *_unused, gpointer* pszURLPattern)
+static void mainwindow_on_web_url_clicked(GtkWidget *_unused, gchar* pszURLPattern)
{
static util_str_replace_t apszReplacements[] = {
{"{LAT}", NULL},
Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- map.c 1 Oct 2005 01:42:12 -0000 1.50
+++ map.c 1 Oct 2005 05:24:16 -0000 1.51
@@ -68,12 +68,14 @@
#define MIN_ZOOMLEVEL_FOR_LOCATIONS (6)
/* Prototypes */
+static void map_init_location_hash(map_t* pMap);
// data loading
static gboolean map_data_load_tiles(map_t* pMap, maprect_t* pRect);
static gboolean map_data_load_geometry(map_t* pMap, maprect_t* pRect);
static gboolean map_data_load_locations(map_t* pMap, maprect_t* pRect);
+
// hit testing
static gboolean map_hit_test_layer_roads(GPtrArray* pPointStringsArray, gdouble fMaxDistance, mappoint_t* pHitPoint, maphit_t** ppReturnStruct);
static gboolean map_hit_test_line(mappoint_t* pPoint1, mappoint_t* pPoint2, mappoint_t* pHitPoint, gdouble fMaxDistance, mappoint_t* pReturnClosestPoint, gdouble* pfReturnPercentAlongLine);
@@ -1250,7 +1252,7 @@
return FALSE;
}
-void map_callback_free_locations_array(gpointer* p)
+void map_callback_free_locations_array(gpointer p)
{
GPtrArray* pLocationsArray = (GPtrArray*)p;
gint i;
Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- map_draw_cairo.c 1 Oct 2005 01:42:12 -0000 1.26
+++ map_draw_cairo.c 1 Oct 2005 05:24:16 -0000 1.27
@@ -55,6 +55,7 @@
#include "location.h"
#include "locationset.h"
#include "scenemanager.h"
+#include "util.h"
// Draw whole layers
static void map_draw_cairo_layer_polygons(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, maplayerstyle_t* pLayerStyle);
Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- map_draw_gdk.c 1 Oct 2005 01:42:12 -0000 1.24
+++ map_draw_gdk.c 1 Oct 2005 05:24:16 -0000 1.25
@@ -138,7 +138,7 @@
// Instead of filling with a color, fill with a tiled image
gdk_gc_get_values(pGC, &gcValues);
gdk_gc_set_fill(pGC, GDK_TILED);
- gdk_gc_set_tile(pGC, glyph_get_pixmap(pLayerStyle->pGlyphFill));
+ gdk_gc_set_tile(pGC, glyph_get_pixmap(pLayerStyle->pGlyphFill, pMap->pTargetWidget));
// This makes the fill image scroll with the map, instead of staying still
gdk_gc_set_ts_origin(pGC, SCALE_X(pRenderMetrics, pRenderMetrics->fScreenLongitude), SCALE_Y(pRenderMetrics, pRenderMetrics->fScreenLatitude));
@@ -192,7 +192,7 @@
// Instead of filling with a color, fill with a tiled image
gdk_gc_get_values(pGC, &gcValues);
gdk_gc_set_fill(pGC, GDK_TILED);
- gdk_gc_set_tile(pGC, glyph_get_pixmap(pLayerStyle->pGlyphFill));
+ gdk_gc_set_tile(pGC, glyph_get_pixmap(pLayerStyle->pGlyphFill, pMap->pTargetWidget));
// This makes the fill image scroll with the map, instead of staying still
gdk_gc_set_ts_origin(pGC, SCALE_X(pRenderMetrics, pRenderMetrics->fScreenLongitude), SCALE_Y(pRenderMetrics, pRenderMetrics->fScreenLatitude));
--- NEW FILE: map_history.c ---
/***************************************************************************
* history.c
*
* Copyright 2005 Ian McIntosh
* ian_mcintosh at linuxadvocate.org
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "main.h"
#include "map.h"
#include "map_history.h"
typedef struct {
mappoint_t MapPoint;
gint nZoomLevel;
} mapview_t;
maphistory_t* map_history_new()
{
maphistory_t* pNew = g_new0(maphistory_t, 1);
pNew->MapViewArray = g_array_new(FALSE, FALSE, sizeof(mapview_t));
pNew->nCurrentIndex = -1;
return pNew;
}
void map_history_add(maphistory_t* pHistory, mappoint_t* pPoint, gint nZoomLevel)
{
g_assert(pHistory != NULL);
g_assert(pPoint != NULL);
// If user has clicked BACK a few times, we won't be at the last index in the array...
if(pHistory->nCurrentIndex < (pHistory->MapViewArray->len - 1)) {
// ...so clear out everything after where we are
g_array_remove_range(pHistory->MapViewArray, pHistory->nCurrentIndex + 1, (pHistory->MapViewArray->len - pHistory->nCurrentIndex) - 1);
pHistory->nTotalItems = (pHistory->nCurrentIndex + 1); // +1 to change it from an index to a count, it's NOT for the new item we're adding
}
// Move to next one
pHistory->nCurrentIndex++;
// Grow array if necessary
if(pHistory->nCurrentIndex >= pHistory->MapViewArray->len) {
// XXX: is this doing a realloc every time? ouch. :)
g_array_set_size(pHistory->MapViewArray, pHistory->MapViewArray->len + 1);
}
// Get pointer to new current index
mapview_t* pNew = &g_array_index(pHistory->MapViewArray, mapview_t, pHistory->nCurrentIndex);
g_return_if_fail(pNew != NULL);
// Save details
memcpy(&(pNew->MapPoint), pPoint, sizeof(mappoint_t));
pNew->nZoomLevel = nZoomLevel;
pHistory->nTotalItems++;
g_assert(pHistory->nCurrentIndex < pHistory->nTotalItems);
}
gboolean map_history_can_go_forward(maphistory_t* pHistory)
{
return(pHistory->nCurrentIndex < (pHistory->nTotalItems - 1));
}
gboolean map_history_can_go_back(maphistory_t* pHistory)
{
return(pHistory->nCurrentIndex > 0);
}
gboolean map_history_go_forward(maphistory_t* pHistory)
{
if(map_history_can_go_forward(pHistory)) {
pHistory->nCurrentIndex++;
return TRUE;
}
}
gboolean map_history_go_back(maphistory_t* pHistory)
{
if(map_history_can_go_back(pHistory)) {
pHistory->nCurrentIndex--;
return TRUE;
}
}
void map_history_get_current(maphistory_t* pHistory, mappoint_t* pReturnPoint, gint* pnReturnZoomLevel)
{
g_assert(pHistory != NULL);
g_assert(pReturnPoint != NULL);
g_assert(pnReturnZoomLevel != NULL);
g_assert(pHistory->nCurrentIndex >= 0);
g_assert(pHistory->nCurrentIndex < pHistory->nTotalItems);
mapview_t* pCurrent = &g_array_index(pHistory->MapViewArray, mapview_t, pHistory->nCurrentIndex);
memcpy(pReturnPoint, &(pCurrent->MapPoint), sizeof(mappoint_t));
*pnReturnZoomLevel = pCurrent->nZoomLevel;
}
--- NEW FILE: map_history.h ---
/***************************************************************************
* history.h
*
* Copyright 2005 Ian McIntosh
* ian_mcintosh at linuxadvocate.org
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _HISTORY_H_
#define _HISTORY_H_
#include "map.h"
typedef struct {
gint nCurrentIndex;
gint nTotalItems;
GArray* MapViewArray;
} maphistory_t;
maphistory_t* map_history_new();
void map_history_add(maphistory_t* pHistory, mappoint_t* pPoint, gint nZoomLevel);
gboolean map_history_can_go_forward(maphistory_t* pHistory);
gboolean map_history_can_go_back(maphistory_t* pHistory);
gboolean map_history_go_forward(maphistory_t* pHistory);
gboolean map_history_go_back(maphistory_t* pHistory);
void map_history_get_current(maphistory_t* pHistory, mappoint_t* pReturnPoint, gint* pnReturnZoomLevel);
#endif
Index: map_style.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_style.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- map_style.c 30 Sep 2005 05:09:51 -0000 1.3
+++ map_style.c 1 Oct 2005 05:24:16 -0000 1.4
@@ -27,6 +27,7 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "main.h"
+#include "glyph.h"
#include "map_style.h"
// utility functions for iterating through lists of XML things
--- tooltip.c DELETED ---
--- tooltip.h DELETED ---
Index: util.c
===================================================================
RCS file: /cvs/cairo/roadster/src/util.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- util.c 30 Sep 2005 05:09:51 -0000 1.13
+++ util.c 1 Oct 2005 05:24:16 -0000 1.14
@@ -177,7 +177,7 @@
{
color_t* pReturnColor = (color_t*)pvReturnColor;
- gchar *p = pszString;
+ const gchar *p = pszString;
if (*p == '#') p++;
if(strlen(p) != 8) {
@@ -409,30 +409,30 @@
//
static void _util_gtk_entry_set_hint_text(GtkEntry* pEntry, const gchar* pszHint)
{
- gtk_widget_modify_text(pEntry, GTK_STATE_NORMAL, &(GTK_WIDGET(pEntry)->style->text_aa[GTK_WIDGET_STATE(pEntry)]));
+ gtk_widget_modify_text(GTK_WIDGET(pEntry), GTK_STATE_NORMAL, &(GTK_WIDGET(pEntry)->style->text_aa[GTK_WIDGET_STATE(pEntry)]));
gtk_entry_set_text(pEntry, pszHint);
}
static void _util_gtk_entry_clear_hint_text(GtkEntry* pEntry)
{
- gtk_widget_modify_text(pEntry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_text(GTK_WIDGET(pEntry), GTK_STATE_NORMAL, NULL);
gtk_entry_set_text(pEntry, "");
}
-static gboolean _util_gtk_entry_on_focus_in_event(GtkEntry* pEntry, GdkEventFocus* _unused, gchar* pszHint)
+static gboolean _util_gtk_entry_on_focus_in_event(GtkEntry* pEntry, GdkEventFocus* _unused, const gchar* pszHint)
{
// If the box is showing pszHint, clear it
- gchar* pszExistingText = gtk_entry_get_text(pEntry);
+ const gchar* pszExistingText = gtk_entry_get_text(pEntry);
if(strcmp(pszExistingText, pszHint) == 0) {
_util_gtk_entry_clear_hint_text(pEntry);
}
return FALSE; // always say we didn't handle it so the normal processing happens
}
-static gboolean _util_gtk_entry_on_focus_out_event(GtkEntry* pEntry, GdkEventFocus* _unused, gchar* pszHint)
+static gboolean _util_gtk_entry_on_focus_out_event(GtkEntry* pEntry, GdkEventFocus* _unused, const gchar* pszHint)
{
// If the box is empty, set the hint text
- gchar* pszExistingText = gtk_entry_get_text(pEntry);
+ const gchar* pszExistingText = gtk_entry_get_text(pEntry);
if(strcmp(pszExistingText, "") == 0) {
_util_gtk_entry_set_hint_text(pEntry, pszHint);
}
@@ -442,8 +442,8 @@
// The API
void util_gtk_entry_add_hint_text(GtkEntry* pEntry, const gchar* pszHint)
{
- g_signal_connect(G_OBJECT(pEntry), "focus-in-event", _util_gtk_entry_on_focus_in_event, pszHint);
- g_signal_connect(G_OBJECT(pEntry), "focus-out-event", _util_gtk_entry_on_focus_out_event, pszHint);
+ g_signal_connect(G_OBJECT(pEntry), "focus-in-event", G_CALLBACK(_util_gtk_entry_on_focus_in_event), (gpointer)pszHint);
+ g_signal_connect(G_OBJECT(pEntry), "focus-out-event", G_CALLBACK(_util_gtk_entry_on_focus_out_event), (gpointer)pszHint);
// 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.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- util.h 30 Sep 2005 05:09:51 -0000 1.13
+++ util.h 1 Oct 2005 05:24:16 -0000 1.14
@@ -72,6 +72,7 @@
} util_str_replace_t;
gchar* util_str_replace_many(const gchar* pszSource, util_str_replace_t* aReplacements, gint nNumReplacements);
+gchar** util_split_words_onto_two_lines(const gchar* pszText, gint nMinLineLength, gint nMaxLineLength);
// GtkEntry "hint"
void util_gtk_entry_add_hint_text(GtkEntry* pEntry, const gchar* pszMessage);
--- welcomewindow.c DELETED ---
--- welcomewindow.h DELETED ---
More information about the cairo-commit
mailing list