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 void ext_tool_class_init ( VikExtToolClass
*klass
);
33 static void ext_tool_init ( VikExtTool
*vlp
);
35 static GObjectClass
*parent_class
;
37 static void ext_tool_finalize ( GObject
*gob
);
38 static gchar
*ext_tool_get_label ( VikExtTool
*vw
);
40 typedef struct _VikExtToolPrivate VikExtToolPrivate
;
42 struct _VikExtToolPrivate
48 #define EXT_TOOL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
52 GType
vik_ext_tool_get_type()
54 static GType w_type
= 0;
58 static const GTypeInfo w_info
=
60 sizeof (VikExtToolClass
),
62 NULL
, /* base_finalize */
63 (GClassInitFunc
) ext_tool_class_init
,
64 NULL
, /* class_finalize */
65 NULL
, /* class_data */
68 (GInstanceInitFunc
) ext_tool_init
,
70 w_type
= g_type_register_static ( G_TYPE_OBJECT
, "VikExtTool", &w_info
, G_TYPE_FLAG_ABSTRACT
);
85 ext_tool_set_property (GObject
*object
,
90 VikExtTool
*self
= VIK_EXT_TOOL (object
);
91 VikExtToolPrivate
*priv
= EXT_TOOL_GET_PRIVATE (self
);
96 priv
->id
= g_value_get_uint (value
);
97 g_debug ("VikExtTool.id: %d", priv
->id
);
101 g_free (priv
->label
);
102 priv
->label
= g_value_dup_string (value
);
103 g_debug ("VikExtTool.label: %s", priv
->label
);
107 /* We don't have any other property... */
108 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
114 ext_tool_get_property (GObject
*object
,
119 VikExtTool
*self
= VIK_EXT_TOOL (object
);
120 VikExtToolPrivate
*priv
= EXT_TOOL_GET_PRIVATE (self
);
125 g_value_set_uint (value
, priv
->id
);
129 g_value_set_string (value
, priv
->label
);
133 /* We don't have any other property... */
134 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
139 static void ext_tool_class_init ( VikExtToolClass
*klass
)
141 GObjectClass
*gobject_class
;
144 gobject_class
= G_OBJECT_CLASS (klass
);
145 gobject_class
->finalize
= ext_tool_finalize
;
146 gobject_class
->set_property
= ext_tool_set_property
;
147 gobject_class
->get_property
= ext_tool_get_property
;
149 pspec
= g_param_spec_string ("label",
152 "<no-set>" /* default value */,
153 G_PARAM_CONSTRUCT_ONLY
| G_PARAM_READWRITE
);
154 g_object_class_install_property (gobject_class
,
158 pspec
= g_param_spec_uint ("id",
161 0 /* minimum value */,
162 G_MAXUINT16
/* maximum value */,
163 0 /* default value */,
164 G_PARAM_CONSTRUCT_ONLY
| G_PARAM_READWRITE
);
165 g_object_class_install_property (gobject_class
,
169 klass
->get_label
= ext_tool_get_label
;
171 parent_class
= g_type_class_peek_parent (klass
);
173 g_type_class_add_private (klass
, sizeof (VikExtToolPrivate
));
176 VikExtTool
*vik_ext_tool_new ()
178 return VIK_EXT_TOOL ( g_object_new ( VIK_EXT_TOOL_TYPE
, NULL
) );
181 static void ext_tool_init ( VikExtTool
*self
)
183 VikExtToolPrivate
*priv
= EXT_TOOL_GET_PRIVATE (self
);
187 static void ext_tool_finalize ( GObject
*gob
)
189 VikExtToolPrivate
*priv
= EXT_TOOL_GET_PRIVATE ( gob
);
190 g_free ( priv
->label
); priv
->label
= NULL
;
191 G_OBJECT_CLASS(parent_class
)->finalize(gob
);
194 static gchar
*ext_tool_get_label ( VikExtTool
*self
)
196 VikExtToolPrivate
*priv
= NULL
;
197 priv
= EXT_TOOL_GET_PRIVATE (self
);
198 return g_strdup ( priv
->label
);
201 gchar
*vik_ext_tool_get_label ( VikExtTool
*w
)
203 return VIK_EXT_TOOL_GET_CLASS( w
)->get_label( w
);
206 void vik_ext_tool_open ( VikExtTool
*self
, VikWindow
*vwindow
)
208 VIK_EXT_TOOL_GET_CLASS( self
)->open( self
, vwindow
);