X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/2bf635ef2201a91e4d9bb2654d0fca9693cc6c62..3684f3627c0d8584f584249383422065ed442a98:/src/googlesearch.c?ds=inline diff --git a/src/googlesearch.c b/src/googlesearch.c index f5e45074..a175ccf9 100644 --- a/src/googlesearch.c +++ b/src/googlesearch.c @@ -1,7 +1,8 @@ /* * viking -- GPS Data and Topo Analyzer, Explorer, and Manager * - * Copyright (C) 2003-2005, Evan Battaglia + * Copyright (C) 2003-2005, Quy Tonthat + * Copyright (C) 2009, Guilhem Bonnefille * * 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 @@ -16,8 +17,6 @@ * 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 - * - * Created by Quy Tonthat */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -36,6 +35,11 @@ #include "googlesearch.h" +/* Compatibility */ +#if ! GLIB_CHECK_VERSION(2,22,0) +#define g_mapped_file_unref g_mapped_file_free +#endif + #define GOOGLE_GOTO_URL_FMT "http://maps.google.com/maps?q=%s&output=js" #define GOOGLE_GOTO_PATTERN_1 "{center:{lat:" #define GOOGLE_GOTO_PATTERN_2 ",lng:" @@ -43,38 +47,13 @@ static DownloadMapOptions googlesearch_options = { FALSE, FALSE, "http://maps.google.com/", 0, a_check_map_file }; -static void google_goto_tool_class_init ( GoogleGotoToolClass *klass ); -static void google_goto_tool_init ( GoogleGotoTool *vwd ); - static void google_goto_tool_finalize ( GObject *gob ); static gchar *google_goto_tool_get_url_format ( VikGotoTool *self ); static DownloadMapOptions *google_goto_tool_get_download_options ( VikGotoTool *self ); static gboolean google_goto_tool_parse_file_for_latlon(VikGotoTool *self, gchar *filename, struct LatLon *ll); -GType google_goto_tool_get_type() -{ - static GType w_type = 0; - - if (!w_type) - { - static const GTypeInfo w_info = - { - sizeof (GoogleGotoToolClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) google_goto_tool_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GoogleGotoTool), - 0, - (GInstanceInitFunc) google_goto_tool_init, - }; - w_type = g_type_register_static ( VIK_GOTO_TOOL_TYPE, "GoogleGotoTool", &w_info, 0 ); - } - - return w_type; -} +G_DEFINE_TYPE (GoogleGotoTool, google_goto_tool, VIK_GOTO_TOOL_TYPE) static void google_goto_tool_class_init ( GoogleGotoToolClass *klass ) { @@ -119,7 +98,7 @@ static gboolean google_goto_tool_parse_file_for_latlon(VikGotoTool *self, gchar if ((mf = g_mapped_file_new(file_name, FALSE, NULL)) == NULL) { g_critical(_("couldn't map temp file")); - exit(1); + return FALSE; } len = g_mapped_file_get_length(mf); text = g_mapped_file_get_contents(mf); @@ -169,7 +148,7 @@ static gboolean google_goto_tool_parse_file_for_latlon(VikGotoTool *self, gchar ll->lon = g_ascii_strtod(lon_buf, NULL); done: - g_mapped_file_free(mf); + g_mapped_file_unref(mf); return (found); }