2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2008, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
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.
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.
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
26 #include "vikexttool.h"
30 #include <glib/gi18n.h>
32 static GObjectClass *parent_class;
34 static void ext_tool_finalize ( GObject *gob );
35 static gchar *ext_tool_get_label ( VikExtTool *vw );
37 typedef struct _VikExtToolPrivate VikExtToolPrivate;
39 struct _VikExtToolPrivate
45 #define EXT_TOOL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
49 G_DEFINE_ABSTRACT_TYPE (VikExtTool, vik_ext_tool, G_TYPE_OBJECT)
60 ext_tool_set_property (GObject *object,
65 VikExtTool *self = VIK_EXT_TOOL (object);
66 VikExtToolPrivate *priv = EXT_TOOL_GET_PRIVATE (self);
71 priv->id = g_value_get_uint (value);
72 g_debug ("VikExtTool.id: %d", priv->id);
77 priv->label = g_value_dup_string (value);
78 g_debug ("VikExtTool.label: %s", priv->label);
82 /* We don't have any other property... */
83 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
89 ext_tool_get_property (GObject *object,
94 VikExtTool *self = VIK_EXT_TOOL (object);
95 VikExtToolPrivate *priv = EXT_TOOL_GET_PRIVATE (self);
100 g_value_set_uint (value, priv->id);
104 g_value_set_string (value, priv->label);
108 /* We don't have any other property... */
109 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
114 static void vik_ext_tool_class_init ( VikExtToolClass *klass )
116 GObjectClass *gobject_class;
119 gobject_class = G_OBJECT_CLASS (klass);
120 gobject_class->finalize = ext_tool_finalize;
121 gobject_class->set_property = ext_tool_set_property;
122 gobject_class->get_property = ext_tool_get_property;
124 pspec = g_param_spec_string ("label",
127 "<no-set>" /* default value */,
128 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
129 g_object_class_install_property (gobject_class,
133 pspec = g_param_spec_uint ("id",
136 0 /* minimum value */,
137 G_MAXUINT16 /* maximum value */,
138 0 /* default value */,
139 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
140 g_object_class_install_property (gobject_class,
144 klass->get_label = ext_tool_get_label;
146 parent_class = g_type_class_peek_parent (klass);
148 g_type_class_add_private (klass, sizeof (VikExtToolPrivate));
151 static void vik_ext_tool_init ( VikExtTool *self )
153 VikExtToolPrivate *priv = EXT_TOOL_GET_PRIVATE (self);
157 static void ext_tool_finalize ( GObject *gob )
159 VikExtToolPrivate *priv = EXT_TOOL_GET_PRIVATE ( gob );
160 g_free ( priv->label ); priv->label = NULL;
161 G_OBJECT_CLASS(parent_class)->finalize(gob);
164 static gchar *ext_tool_get_label ( VikExtTool *self )
166 VikExtToolPrivate *priv = NULL;
167 priv = EXT_TOOL_GET_PRIVATE (self);
168 return g_strdup ( priv->label );
171 gchar *vik_ext_tool_get_label ( VikExtTool *w )
173 return VIK_EXT_TOOL_GET_CLASS( w )->get_label( w );
176 void vik_ext_tool_open ( VikExtTool *self, VikWindow *vwindow )
178 VIK_EXT_TOOL_GET_CLASS( self )->open( self, vwindow );