]> git.street.me.uk Git - andy/viking.git/blame - src/vikwebtool.c
Support all values of GPS Mode fixType.
[andy/viking.git] / src / vikwebtool.c
CommitLineData
92806042
GB
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2008, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#include "vikwebtool.h"
27
28#include <string.h>
29
30#include <glib/gi18n.h>
31
ec77010a 32#include "ui_util.h"
92806042 33
92806042
GB
34static GObjectClass *parent_class;
35
36static void webtool_finalize ( GObject *gob );
37
38static void webtool_open ( VikExtTool *self, VikWindow *vwindow );
027ff770 39static void webtool_open_at_position ( VikExtTool *self, VikWindow *vwindow, VikCoord *vc );
92806042 40
bb440ed1 41G_DEFINE_ABSTRACT_TYPE (VikWebtool, vik_webtool, VIK_EXT_TOOL_TYPE)
92806042 42
bb440ed1 43static void vik_webtool_class_init ( VikWebtoolClass *klass )
92806042
GB
44{
45 GObjectClass *object_class;
46 VikExtToolClass *ext_tool_class;
47
48 object_class = G_OBJECT_CLASS (klass);
49
50 object_class->finalize = webtool_finalize;
51
52 parent_class = g_type_class_peek_parent (klass);
53
54 ext_tool_class = VIK_EXT_TOOL_CLASS ( klass );
55 ext_tool_class->open = webtool_open;
027ff770 56 ext_tool_class->open_at_position = webtool_open_at_position;
92806042
GB
57}
58
59VikWebtool *vik_webtool_new ()
60{
61 return VIK_WEBTOOL ( g_object_new ( VIK_WEBTOOL_TYPE, NULL ) );
62}
63
bb440ed1 64static void vik_webtool_init ( VikWebtool *vlp )
92806042 65{
bb440ed1 66 // NOTHING
92806042
GB
67}
68
69static void webtool_finalize ( GObject *gob )
70{
71 // VikWebtool *w = VIK_WEBTOOL ( gob );
72 G_OBJECT_CLASS(parent_class)->finalize(gob);
73}
74
75static void webtool_open ( VikExtTool *self, VikWindow *vwindow )
76{
77 VikWebtool *vwd = VIK_WEBTOOL ( self );
78 gchar *url = vik_webtool_get_url ( vwd, vwindow );
adaab195 79 open_url ( GTK_WINDOW(vwindow), url );
92806042
GB
80 g_free ( url );
81}
82
027ff770
RN
83static void webtool_open_at_position ( VikExtTool *self, VikWindow *vwindow, VikCoord *vc )
84{
85 VikWebtool *vwd = VIK_WEBTOOL ( self );
86 gchar *url = vik_webtool_get_url_at_position ( vwd, vwindow, vc );
87 if ( url ) {
88 open_url ( GTK_WINDOW(vwindow), url );
89 g_free ( url );
90 }
91}
92
92806042
GB
93gchar *vik_webtool_get_url ( VikWebtool *self, VikWindow *vwindow )
94{
95 return VIK_WEBTOOL_GET_CLASS( self )->get_url( self, vwindow );
96}
027ff770
RN
97
98gchar *vik_webtool_get_url_at_position ( VikWebtool *self, VikWindow *vwindow, VikCoord *vc )
99{
100 if ( VIK_WEBTOOL_GET_CLASS( self )->get_url_at_position )
101 return VIK_WEBTOOL_GET_CLASS( self )->get_url_at_position( self, vwindow, vc );
102 else
103 return NULL;
104}