3 #include "aweather-view.h"
5 G_DEFINE_TYPE(AWeatherView, aweather_view, G_TYPE_OBJECT);
19 static guint signals[NUM_SIGNALS];
21 /* Constructor / destructors */
22 static void aweather_view_init(AWeatherView *self)
24 //g_message("aweather_view_init");
27 self->location = g_strdup("IND");
30 static GObject *aweather_view_constructor(GType gtype, guint n_properties,
31 GObjectConstructParam *properties)
33 //g_message("aweather_view_constructor");
34 GObjectClass *parent_class = G_OBJECT_CLASS(aweather_view_parent_class);
35 return parent_class->constructor(gtype, n_properties, properties);
38 static void aweather_view_dispose (GObject *gobject)
40 //g_message("aweather_view_dispose");
41 /* Drop references to other GObjects */
42 G_OBJECT_CLASS(aweather_view_parent_class)->dispose(gobject);
45 static void aweather_view_finalize(GObject *gobject)
47 //g_message("aweather_view_finalize");
48 AWeatherView *self = AWEATHER_VIEW(gobject);
49 g_free(self->location);
50 G_OBJECT_CLASS(aweather_view_parent_class)->finalize(gobject);
53 static void aweather_view_set_property(GObject *object, guint property_id,
54 const GValue *value, GParamSpec *pspec)
56 //g_message("aweather_view_set_property");
57 AWeatherView *self = AWEATHER_VIEW(object);
58 switch (property_id) {
59 case PROP_TIME: aweather_view_set_time (self, g_value_get_int (value)); break;
60 case PROP_LOCATION: aweather_view_set_location(self, g_value_get_string(value)); break;
61 default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
65 static void aweather_view_get_property(GObject *object, guint property_id,
66 GValue *value, GParamSpec *pspec)
68 //g_message("aweather_view_get_property");
69 AWeatherView *self = AWEATHER_VIEW(object);
70 switch (property_id) {
71 case PROP_TIME: g_value_set_int (value, aweather_view_get_time (self)); break;
72 case PROP_LOCATION: g_value_set_string(value, aweather_view_get_location(self)); break;
73 default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
77 static void aweather_view_class_init(AWeatherViewClass *klass)
79 //g_message("aweather_view_class_init");
80 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
81 gobject_class->constructor = aweather_view_constructor;
82 gobject_class->dispose = aweather_view_dispose;
83 gobject_class->finalize = aweather_view_finalize;
84 gobject_class->get_property = aweather_view_get_property;
85 gobject_class->set_property = aweather_view_set_property;
86 g_object_class_install_property(gobject_class, PROP_TIME,
89 "time of the current frame",
91 G_MININT32, G_MAXINT32, 0,
93 g_object_class_install_property(gobject_class, PROP_LOCATION,
96 "location seen by the viewport",
97 "Location of the viewport. Currently this is the name of the radar site.",
99 signals[SIG_TIME_CHANGED] = g_signal_new(
101 G_TYPE_FROM_CLASS(gobject_class),
106 g_cclosure_marshal_VOID__INT,
110 signals[SIG_LOCATION_CHANGED] = g_signal_new(
112 G_TYPE_FROM_CLASS(gobject_class),
117 g_cclosure_marshal_VOID__STRING,
125 AWeatherView *aweather_view_new()
127 //g_message("aweather_view_new");
128 return g_object_new(AWEATHER_TYPE_VIEW, NULL);
131 void aweather_view_set_time(AWeatherView *view, int time)
133 g_assert(AWEATHER_IS_VIEW(view));
134 //g_message("aweather_view_set_time");
136 g_signal_emit(view, signals[SIG_TIME_CHANGED], 0, time);
139 int aweather_view_get_time(AWeatherView *view)
141 g_assert(AWEATHER_IS_VIEW(view));
142 //g_message("aweather_view_get_time");
146 void aweather_view_set_location(AWeatherView *view, const gchar *location)
148 g_assert(AWEATHER_IS_VIEW(view));
149 //g_message("aweather_view_set_location");
150 g_free(view->location);
151 view->location = g_strdup(location);
152 g_signal_emit(view, signals[SIG_LOCATION_CHANGED], 0, view->location);
155 gchar *aweather_view_get_location(AWeatherView *view)
157 g_assert(AWEATHER_IS_VIEW(view));
158 //g_message("aweather_view_get_location");
159 return view->location;