2 * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "aweather-view.h"
22 G_DEFINE_TYPE(AWeatherView, aweather_view, G_TYPE_OBJECT);
37 static guint signals[NUM_SIGNALS];
39 /* Constructor / destructors */
40 static void aweather_view_init(AWeatherView *self)
42 //g_message("aweather_view_init");
44 self->time = g_strdup(""); //g_strdup("LATEST");
45 self->location = g_strdup(""); //g_strdup("IND");
48 static GObject *aweather_view_constructor(GType gtype, guint n_properties,
49 GObjectConstructParam *properties)
51 //g_message("aweather_view_constructor");
52 GObjectClass *parent_class = G_OBJECT_CLASS(aweather_view_parent_class);
53 return parent_class->constructor(gtype, n_properties, properties);
56 static void aweather_view_dispose (GObject *gobject)
58 //g_message("aweather_view_dispose");
59 /* Drop references to other GObjects */
60 G_OBJECT_CLASS(aweather_view_parent_class)->dispose(gobject);
63 static void aweather_view_finalize(GObject *gobject)
65 //g_message("aweather_view_finalize");
66 AWeatherView *self = AWEATHER_VIEW(gobject);
67 g_free(self->location);
68 G_OBJECT_CLASS(aweather_view_parent_class)->finalize(gobject);
71 static void aweather_view_set_property(GObject *object, guint property_id,
72 const GValue *value, GParamSpec *pspec)
74 //g_message("aweather_view_set_property");
75 AWeatherView *self = AWEATHER_VIEW(object);
76 switch (property_id) {
77 case PROP_TIME: aweather_view_set_time (self, g_value_get_string(value)); break;
78 case PROP_LOCATION: aweather_view_set_location(self, g_value_get_string(value)); break;
79 default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
83 static void aweather_view_get_property(GObject *object, guint property_id,
84 GValue *value, GParamSpec *pspec)
86 //g_message("aweather_view_get_property");
87 AWeatherView *self = AWEATHER_VIEW(object);
88 switch (property_id) {
89 case PROP_TIME: g_value_set_string(value, aweather_view_get_time (self)); break;
90 case PROP_LOCATION: g_value_set_string(value, aweather_view_get_location(self)); break;
91 default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
95 static void aweather_view_class_init(AWeatherViewClass *klass)
97 //g_message("aweather_view_class_init");
98 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
99 gobject_class->constructor = aweather_view_constructor;
100 gobject_class->dispose = aweather_view_dispose;
101 gobject_class->finalize = aweather_view_finalize;
102 gobject_class->get_property = aweather_view_get_property;
103 gobject_class->set_property = aweather_view_set_property;
104 g_object_class_install_property(gobject_class, PROP_TIME,
105 g_param_spec_pointer(
107 "time of the current frame",
110 g_object_class_install_property(gobject_class, PROP_LOCATION,
111 g_param_spec_pointer(
113 "location seen by the viewport",
114 "Location of the viewport. Currently this is the name of the radar site.",
116 signals[SIG_TIME_CHANGED] = g_signal_new(
118 G_TYPE_FROM_CLASS(gobject_class),
123 g_cclosure_marshal_VOID__INT,
127 signals[SIG_LOCATION_CHANGED] = g_signal_new(
129 G_TYPE_FROM_CLASS(gobject_class),
134 g_cclosure_marshal_VOID__STRING,
138 signals[SIG_REFRESH] = g_signal_new(
140 G_TYPE_FROM_CLASS(gobject_class),
145 g_cclosure_marshal_VOID__VOID,
152 AWeatherView *aweather_view_new()
154 //g_message("aweather_view_new");
155 return g_object_new(AWEATHER_TYPE_VIEW, NULL);
158 void aweather_view_set_time(AWeatherView *view, const char *time)
160 g_assert(AWEATHER_IS_VIEW(view));
161 //g_message("aweather_view:set_time: setting time to %s", time);
163 view->time = g_strdup(time);
164 g_signal_emit(view, signals[SIG_TIME_CHANGED], 0, time);
167 gchar *aweather_view_get_time(AWeatherView *view)
169 g_assert(AWEATHER_IS_VIEW(view));
170 //g_message("aweather_view_get_time");
174 void aweather_view_set_location(AWeatherView *view, const gchar *location)
176 g_assert(AWEATHER_IS_VIEW(view));
177 //g_message("aweather_view_set_location");
178 g_free(view->location);
179 view->location = g_strdup(location);
180 g_signal_emit(view, signals[SIG_LOCATION_CHANGED], 0, view->location);
183 gchar *aweather_view_get_location(AWeatherView *view)
185 g_assert(AWEATHER_IS_VIEW(view));
186 //g_message("aweather_view_get_location");
187 return view->location;
190 void aweather_view_refresh(AWeatherView *view)
192 g_message("aweather_view_refresh: ..");
193 g_signal_emit(view, signals[SIG_REFRESH], 0);
196 void aweather_view_zoomin(AWeatherView *view)
198 g_message("aweather_view_zoomin: ..");
201 void aweather_view_zoomout(AWeatherView *view)
203 g_message("aweather_view_zoomout: ..");