]> git.street.me.uk Git - andy/viking.git/blame - src/vikwaypoint.c
Relocating icons.h in order to better handle its prodution
[andy/viking.git] / src / vikwaypoint.c
CommitLineData
50a14534
EB
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
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#include <glib.h>
23#include "coords.h"
24#include "vikcoord.h"
25#include "vikwaypoint.h"
26
acaf7113 27
50a14534
EB
28VikWaypoint *vik_waypoint_new()
29{
30 VikWaypoint *wp = g_malloc ( sizeof ( VikWaypoint ) );
31 wp->comment = NULL;
32 wp->image = NULL;
acaf7113 33 wp->symbol = NULL;
50a14534
EB
34 return wp;
35}
36
37void vik_waypoint_set_comment_no_copy(VikWaypoint *wp, gchar *comment)
38{
39 if ( wp->comment )
40 g_free ( wp->comment );
41 wp->comment = comment;
42}
43
44void vik_waypoint_set_comment(VikWaypoint *wp, const gchar *comment)
45{
46 if ( wp->comment )
47 g_free ( wp->comment );
48
49 if ( comment && comment[0] != '\0' )
50 wp->comment = g_strdup(comment);
51 else
52 wp->comment = NULL;
53}
54
55void vik_waypoint_set_image(VikWaypoint *wp, const gchar *image)
56{
57 if ( wp->image )
58 g_free ( wp->image );
59
60 if ( image && image[0] != '\0' )
61 wp->image = g_strdup(image);
62 else
63 wp->image = NULL;
64}
65
acaf7113
AF
66void vik_waypoint_set_symbol(VikWaypoint *wp, const gchar *symname)
67{
68 if ( wp->symbol )
69 g_free ( wp->symbol );
70
71 if ( symname && symname[0] != '\0' )
72 wp->symbol = g_strdup(symname);
73 else
74 wp->symbol = NULL;
75}
76
50a14534
EB
77void vik_waypoint_free(VikWaypoint *wp)
78{
79 if ( wp->comment )
80 g_free ( wp->comment );
81 if ( wp->image )
82 g_free ( wp->image );
acaf7113
AF
83 if ( wp->symbol )
84 g_free ( wp->symbol );
50a14534
EB
85 g_free ( wp );
86}
87
88VikWaypoint *vik_waypoint_copy(const VikWaypoint *wp)
89{
90 VikWaypoint *new_wp = vik_waypoint_new();
91 *new_wp = *wp;
92 new_wp->comment = NULL; /* if the waypoint had a comment, FOR CRYING OUT LOUD DON'T FREE IT! This lousy bug took me TWO HOURS to figure out... sigh... */
93 vik_waypoint_set_comment(new_wp,wp->comment);
94 new_wp->image = NULL;
95 vik_waypoint_set_image(new_wp,wp->image);
acaf7113
AF
96 new_wp->symbol = NULL;
97 vik_waypoint_set_symbol(new_wp,wp->symbol);
50a14534
EB
98 return new_wp;
99}
acaf7113 100