2 * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
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/>.
21 #include <glib/gstdio.h>
23 #include <gtk/gtkgl.h>
33 #include "../aweather-location.h"
35 GtkWidget *_gtk_check_label_new(const gchar *text, gboolean state,
36 GCallback on_clicked, gpointer user_data)
38 GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
39 GtkWidget *check = gtk_check_button_new();
40 GtkWidget *label = gtk_label_new(text);
41 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), state);
42 g_signal_connect_swapped(check , "clicked",
43 G_CALLBACK(on_clicked), user_data);
44 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
45 gtk_box_pack_end(GTK_BOX(hbox), check , FALSE, FALSE, 0);
46 gtk_widget_show_all(hbox);
50 void _gtk_bin_set_child(GtkBin *bin, GtkWidget *new)
52 GtkWidget *old = gtk_bin_get_child(bin);
54 gtk_widget_destroy(old);
55 gtk_container_add(GTK_CONTAINER(bin), new);
56 gtk_widget_show_all(new);
59 static gchar *_find_nearest(time_t time, GList *files,
60 gsize offset, gchar *format)
62 g_debug("RadarSite: find_nearest ...");
63 time_t nearest_time = 0;
64 char *nearest_file = NULL;
67 for (GList *cur = files; cur; cur = cur->next) {
68 gchar *file = cur->data;
69 strptime(file+offset, format, &tm);
70 if (ABS(time - mktime(&tm)) <
71 ABS(time - nearest_time)) {
73 nearest_time = mktime(&tm);
77 g_debug("RadarSite: find_nearest = %s", nearest_file);
79 return g_strdup(nearest_file);
96 GritsMarker *marker; // Map marker for grits
97 gpointer *marker_ref; // Reference to maker
99 /* Stuff from the parents */
107 RadarSiteStatus status; // Loading status for the site
109 AWeatherLevel2 *level2; // The Level2 structure for the current volume
110 gpointer level2_ref; // GritsViewer reference to the added radar
113 time_t time; // Current timestamp of the level2
114 gchar *message; // Error message set while updating
115 guint time_id; // "time-changed" callback ID
116 guint refresh_id; // "refresh" callback ID
117 guint location_id; // "locaiton-changed" callback ID
120 /* format: http://mesonet.agron.iastate.edu/data/nexrd2/raw/KABR/KABR_20090510_0323 */
121 void _site_update_loading(gchar *file, goffset cur,
122 goffset total, gpointer _site)
124 RadarSite *site = _site;
125 GtkWidget *progress_bar = gtk_bin_get_child(GTK_BIN(site->config));
126 double percent = (double)cur/total;
127 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), MIN(percent, 1.0));
128 gchar *msg = g_strdup_printf("Loading... %5.1f%% (%.2f/%.2f MB)",
129 percent*100, (double)cur/1000000, (double)total/1000000);
130 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), msg);
133 gboolean _site_update_end(gpointer _site)
135 RadarSite *site = _site;
137 g_warning("RadarSite: update_end - %s", site->message);
138 _gtk_bin_set_child(GTK_BIN(site->config),
139 gtk_label_new(site->message));
141 _gtk_bin_set_child(GTK_BIN(site->config),
142 aweather_level2_get_config(site->level2));
144 site->status = STATUS_LOADED;
147 gpointer _site_update_thread(gpointer _site)
149 RadarSite *site = _site;
150 g_debug("RadarSite: update_thread - %s", site->city->code);
151 site->message = NULL;
153 gboolean offline = grits_viewer_get_offline(site->viewer);
154 gchar *nexrad_url = grits_prefs_get_string(site->prefs,
155 "aweather/nexrad_url", NULL);
157 /* Find nearest volume (temporally) */
158 g_debug("RadarSite: update_thread - find nearest - %s", site->city->code);
159 gchar *dir_list = g_strconcat(nexrad_url, "/", site->city->code,
160 "/", "dir.list", NULL);
161 GList *files = grits_http_available(site->http,
162 "^K\\w{3}_\\d{8}_\\d{4}$", site->city->code,
163 "\\d+ (.*)", (offline ? NULL : dir_list));
165 gchar *nearest = _find_nearest(site->time, files, 5, "%Y%m%d_%H%M");
166 g_list_foreach(files, (GFunc)g_free, NULL);
169 site->message = "No suitable files found";
173 /* Fetch new volume */
174 g_debug("RadarSite: update_thread - fetch");
175 gchar *local = g_strconcat(site->city->code, "/", nearest, NULL);
176 gchar *uri = g_strconcat(nexrad_url, "/", local, NULL);
177 gchar *file = grits_http_fetch(site->http, uri, local,
178 offline ? GRITS_LOCAL : GRITS_UPDATE,
179 _site_update_loading, site);
185 site->message = "Fetch failed";
189 /* Load and add new volume */
190 g_debug("RadarSite: update_thread - load - %s", site->city->code);
191 site->level2 = aweather_level2_new_from_file(
192 file, site->city->code, colormaps);
195 site->message = "Load failed";
198 GRITS_OBJECT(site->level2)->hidden = site->hidden;
199 site->level2_ref = grits_viewer_add(site->viewer,
200 GRITS_OBJECT(site->level2), GRITS_LEVEL_WORLD, TRUE);
203 g_idle_add(_site_update_end, site);
206 void _site_update(RadarSite *site)
208 if (site->status == STATUS_LOADING)
210 site->status = STATUS_LOADING;
212 site->time = grits_viewer_get_time(site->viewer);
213 g_debug("RadarSite: update %s - %d",
214 site->city->code, (gint)site->time);
216 /* Add a progress bar */
217 GtkWidget *progress = gtk_progress_bar_new();
218 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Loading...");
219 _gtk_bin_set_child(GTK_BIN(site->config), progress);
221 /* Remove old volume */
222 g_debug("RadarSite: update - remove - %s", site->city->code);
223 if (site->level2_ref) {
224 grits_viewer_remove(site->viewer, site->level2_ref);
225 site->level2_ref = NULL;
228 /* Fork loading right away so updating the
229 * list of times doesn't take too long */
230 g_thread_create(_site_update_thread, site, FALSE, NULL);
233 /* RadarSite methods */
234 void radar_site_unload(RadarSite *site)
236 if (site->status != STATUS_LOADED)
237 return; // Abort if it's still loading
239 g_debug("RadarSite: unload %s", site->city->code);
242 g_signal_handler_disconnect(site->viewer, site->time_id);
243 if (site->refresh_id)
244 g_signal_handler_disconnect(site->viewer, site->refresh_id);
248 gtk_widget_destroy(site->config);
251 if (site->level2_ref) {
252 grits_viewer_remove(site->viewer, site->level2_ref);
253 site->level2_ref = NULL;
256 site->status = STATUS_UNLOADED;
259 void radar_site_toggle(RadarSite *site)
261 site->hidden = !site->hidden;
263 GRITS_OBJECT(site->level2)->hidden = site->hidden;
264 gtk_widget_queue_draw(GTK_WIDGET(site->viewer));
268 void radar_site_load(RadarSite *site)
270 g_debug("RadarSite: load %s", site->city->code);
273 site->config = gtk_alignment_new(0, 0, 1, 1);
274 gtk_notebook_append_page(GTK_NOTEBOOK(site->pconfig), site->config,
275 _gtk_check_label_new(site->city->name, !site->hidden,
276 G_CALLBACK(radar_site_toggle), site));
277 gtk_widget_show_all(site->config);
279 /* Set up radar loading */
280 site->time_id = g_signal_connect_swapped(site->viewer, "time-changed",
281 G_CALLBACK(_site_update), site);
282 site->refresh_id = g_signal_connect_swapped(site->viewer, "refresh",
283 G_CALLBACK(_site_update), site);
287 void _site_on_location_changed(GritsViewer *viewer,
288 gdouble lat, gdouble lon, gdouble elev,
291 static gdouble min_dist = EARTH_R / 30;
292 RadarSite *site = _site;
294 /* Calculate distance, could cache xyz values */
295 gdouble eye_xyz[3], site_xyz[3];
296 lle2xyz(lat, lon, elev, &eye_xyz[0], &eye_xyz[1], &eye_xyz[2]);
297 lle2xyz(site->city->pos.lat, site->city->pos.lon, site->city->pos.elev,
298 &site_xyz[0], &site_xyz[1], &site_xyz[2]);
299 gdouble dist = distd(site_xyz, eye_xyz);
301 /* Load or unload the site if necessasairy */
302 if (dist <= min_dist && dist < elev*1.25 && site->status == STATUS_UNLOADED)
303 radar_site_load(site);
304 else if (dist > 2*min_dist && site->status != STATUS_UNLOADED)
305 radar_site_unload(site);
308 gboolean _site_add_marker(gpointer _site)
310 RadarSite *site = _site;
311 site->marker = grits_marker_new(site->city->name);
312 GRITS_OBJECT(site->marker)->center = site->city->pos;
313 GRITS_OBJECT(site->marker)->lod = EARTH_R*site->city->lod;
314 site->marker_ref = grits_viewer_add(site->viewer,
315 GRITS_OBJECT(site->marker), GRITS_LEVEL_OVERLAY, FALSE);
318 RadarSite *radar_site_new(city_t *city, GtkWidget *pconfig,
319 GritsViewer *viewer, GritsPrefs *prefs, GritsHttp *http)
321 RadarSite *site = g_new0(RadarSite, 1);
322 site->viewer = g_object_ref(viewer);
323 site->prefs = g_object_ref(prefs);
325 site->http = grits_http_new(G_DIR_SEPARATOR_S
326 "nexrad" G_DIR_SEPARATOR_S
327 "level2" G_DIR_SEPARATOR_S);
329 site->pconfig = pconfig;
332 g_idle_add_full(G_PRIORITY_LOW, _site_add_marker, site, NULL);
335 /* Connect signals */
336 site->location_id = g_signal_connect(viewer, "location-changed",
337 G_CALLBACK(_site_on_location_changed), site);
341 void radar_site_free(RadarSite *site)
343 radar_site_unload(site);
344 grits_viewer_remove(site->viewer, site->marker_ref);
345 if (site->location_id)
346 g_signal_handler_disconnect(site->viewer, site->location_id);
347 grits_http_free(site->http);
348 g_object_unref(site->viewer);
349 g_object_unref(site->prefs);
357 #define CONUS_NORTH 50.406626367301044
358 #define CONUS_WEST -127.620375523875420
359 #define CONUS_WIDTH 3400.0
360 #define CONUS_HEIGHT 1600.0
361 #define CONUS_DEG_PER_PX 0.017971305190311
368 const gchar *message;
369 GStaticMutex loading;
373 gpointer *tile_ref[2];
375 guint time_id; // "time-changed" callback ID
376 guint refresh_id; // "refresh" callback ID
379 void _conus_update_loading(gchar *file, goffset cur,
380 goffset total, gpointer _conus)
382 RadarConus *conus = _conus;
383 GtkWidget *progress_bar = gtk_bin_get_child(GTK_BIN(conus->config));
384 double percent = (double)cur/total;
385 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), MIN(percent, 1.0));
386 gchar *msg = g_strdup_printf("Loading... %5.1f%% (%.2f/%.2f MB)",
387 percent*100, (double)cur/1000000, (double)total/1000000);
388 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), msg);
392 /* Copy images to graphics memory */
393 static void _conus_update_end_copy(GritsTile *tile, guchar *pixels)
396 tile->data = g_new0(guint, 1);
397 glGenTextures(1, tile->data);
400 guint *tex = tile->data;
401 glBindTexture(GL_TEXTURE_2D, *tex);
403 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
404 glPixelStorei(GL_PACK_ALIGNMENT, 1);
405 glTexImage2D(GL_TEXTURE_2D, 0, 4, 2048, 2048, 0,
406 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
407 glTexSubImage2D(GL_TEXTURE_2D, 0, 1,1, CONUS_WIDTH/2,CONUS_HEIGHT,
408 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
409 tile->coords.n = 1.0/(CONUS_WIDTH/2);
410 tile->coords.w = 1.0/ CONUS_HEIGHT;
411 tile->coords.s = tile->coords.n + CONUS_HEIGHT / 2048.0;
412 tile->coords.e = tile->coords.w + (CONUS_WIDTH/2) / 2048.0;
413 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
414 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
415 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
416 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
420 /* Split the pixbuf into east and west halves (with 2K sides)
421 * Also map the pixbuf's alpha values */
422 static void _conus_update_end_split(guchar *pixels, guchar *west, guchar *east,
423 gint width, gint height, gint pxsize)
425 g_debug("Conus: update_end_split");
426 guchar *out[] = {west,east};
427 const guchar alphamap[][4] = {
428 {0x04, 0xe9, 0xe7, 0x30},
429 {0x01, 0x9f, 0xf4, 0x60},
430 {0x03, 0x00, 0xf4, 0x90},
432 for (int y = 0; y < height; y++)
433 for (int x = 0; x < width; x++) {
434 gint subx = x % (width/2);
435 gint idx = x / (width/2);
436 guchar *src = &pixels[(y*width+x)*pxsize];
437 guchar *dst = &out[idx][(y*(width/2)+subx)*4];
447 for (int j = 0; j < G_N_ELEMENTS(alphamap); j++)
448 if (src[0] == alphamap[j][0] &&
449 src[1] == alphamap[j][1] &&
450 src[2] == alphamap[j][2])
451 dst[3] = alphamap[j][3];
456 gboolean _conus_update_end(gpointer _conus)
458 RadarConus *conus = _conus;
459 g_debug("Conus: update_end");
461 /* Check error status */
462 if (conus->message) {
463 g_warning("Conus: update_end - %s", conus->message);
464 _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new(conus->message));
468 /* Load and pixbuf */
469 GError *error = NULL;
470 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(conus->path, &error);
471 if (!pixbuf || error) {
472 g_warning("Conus: update_end - error loading pixbuf");
473 _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new("Error loading pixbuf"));
474 g_remove(conus->path);
478 /* Split pixels into east/west parts */
479 guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
480 gint width = gdk_pixbuf_get_width(pixbuf);
481 gint height = gdk_pixbuf_get_height(pixbuf);
482 gint pxsize = gdk_pixbuf_get_has_alpha(pixbuf) ? 4 : 3;
483 guchar *pixels_west = g_malloc(4*(width/2)*height);
484 guchar *pixels_east = g_malloc(4*(width/2)*height);
485 _conus_update_end_split(pixels, pixels_west, pixels_east,
486 width, height, pxsize);
487 g_object_unref(pixbuf);
489 /* Copy pixels to graphics memory */
490 _conus_update_end_copy(conus->tile[0], pixels_west);
491 _conus_update_end_copy(conus->tile[1], pixels_east);
496 gchar *label = g_path_get_basename(conus->path);
497 _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new(label));
498 gtk_widget_queue_draw(GTK_WIDGET(conus->viewer));
503 g_static_mutex_unlock(&conus->loading);
507 gpointer _conus_update_thread(gpointer _conus)
509 RadarConus *conus = _conus;
510 conus->message = NULL;
513 g_debug("Conus: update_thread - nearest");
514 gboolean offline = grits_viewer_get_offline(conus->viewer);
515 gchar *conus_url = "http://radar.weather.gov/Conus/RadarImg/";
516 GList *files = grits_http_available(conus->http,
517 "^Conus_[^\"]*_N0Ronly.gif$", "",
518 NULL, (offline ? NULL : conus_url));
519 gchar *nearest = _find_nearest(conus->time, files, 6, "%Y%m%d_%H%M");
520 g_list_foreach(files, (GFunc)g_free, NULL);
523 conus->message = "No suitable files";
527 /* Fetch the image */
528 g_debug("Conus: update_thread - fetch");
529 gchar *uri = g_strconcat(conus_url, nearest, NULL);
530 conus->path = grits_http_fetch(conus->http, uri, nearest, GRITS_ONCE,
531 _conus_update_loading, conus);
535 conus->message = "Fetch failed";
540 g_debug("Conus: update_thread - done");
541 g_idle_add(_conus_update_end, conus);
545 void _conus_update(RadarConus *conus)
547 if (!g_static_mutex_trylock(&conus->loading))
549 conus->time = grits_viewer_get_time(conus->viewer);
550 g_debug("Conus: update - %d",
553 /* Add a progress bar */
554 GtkWidget *progress = gtk_progress_bar_new();
555 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Loading...");
556 _gtk_bin_set_child(GTK_BIN(conus->config), progress);
558 g_thread_create(_conus_update_thread, conus, FALSE, NULL);
561 void radar_conus_toggle(RadarConus *conus)
563 GRITS_OBJECT(conus->tile[0])->hidden =
564 !GRITS_OBJECT(conus->tile[0])->hidden;
565 GRITS_OBJECT(conus->tile[1])->hidden =
566 !GRITS_OBJECT(conus->tile[1])->hidden;
567 gtk_widget_queue_draw(GTK_WIDGET(conus->viewer));
570 RadarConus *radar_conus_new(GtkWidget *pconfig,
571 GritsViewer *viewer, GritsHttp *http)
573 RadarConus *conus = g_new0(RadarConus, 1);
574 conus->viewer = g_object_ref(viewer);
576 conus->config = gtk_alignment_new(0, 0, 1, 1);
577 g_static_mutex_init(&conus->loading);
579 gdouble south = CONUS_NORTH - CONUS_DEG_PER_PX*CONUS_HEIGHT;
580 gdouble east = CONUS_WEST + CONUS_DEG_PER_PX*CONUS_WIDTH;
581 gdouble mid = CONUS_WEST + CONUS_DEG_PER_PX*CONUS_WIDTH/2;
582 conus->tile[0] = grits_tile_new(NULL, CONUS_NORTH, south, mid, CONUS_WEST);
583 conus->tile[1] = grits_tile_new(NULL, CONUS_NORTH, south, east, mid);
584 conus->tile[0]->zindex = 2;
585 conus->tile[1]->zindex = 1;
586 conus->tile_ref[0] = grits_viewer_add(viewer,
587 GRITS_OBJECT(conus->tile[0]), GRITS_LEVEL_WORLD, TRUE);
588 conus->tile_ref[1] = grits_viewer_add(viewer,
589 GRITS_OBJECT(conus->tile[1]), GRITS_LEVEL_WORLD, TRUE);
591 conus->time_id = g_signal_connect_swapped(viewer, "time-changed",
592 G_CALLBACK(_conus_update), conus);
593 conus->refresh_id = g_signal_connect_swapped(viewer, "refresh",
594 G_CALLBACK(_conus_update), conus);
596 gtk_notebook_append_page(GTK_NOTEBOOK(pconfig), conus->config,
597 _gtk_check_label_new("Conus", TRUE,
598 G_CALLBACK(radar_conus_toggle), conus));
599 _conus_update(conus);
603 void radar_conus_free(RadarConus *conus)
605 g_signal_handler_disconnect(conus->viewer, conus->time_id);
606 g_signal_handler_disconnect(conus->viewer, conus->refresh_id);
608 for (int i = 0; i < 2; i++) {
609 GritsTile *tile = conus->tile[i];
610 gpointer ref = conus->tile_ref[i];
612 glDeleteTextures(1, tile->data);
615 grits_viewer_remove(conus->viewer, ref);
618 g_object_unref(conus->viewer);
623 /********************
625 ********************/
626 static void _draw_hud(GritsCallback *callback, GritsOpenGL *opengl, gpointer _self)
628 /* TODO, pick correct colormaps */
629 AWeatherColormap *colormap = &colormaps[0];
631 g_debug("GritsPluginRadar: _draw_hud");
632 /* Print the color table */
633 glMatrixMode(GL_MODELVIEW ); glLoadIdentity();
634 glMatrixMode(GL_PROJECTION); glLoadIdentity();
635 glDisable(GL_TEXTURE_2D);
636 glDisable(GL_ALPHA_TEST);
637 glDisable(GL_CULL_FACE);
638 glDisable(GL_LIGHTING);
639 glEnable(GL_COLOR_MATERIAL);
642 for (i = 0; i < 256; i++) {
643 glColor4ubv(colormap->data[i]);
644 glVertex3f(-1.0, (float)((i ) - 256/2)/(256/2), 0.0); // bot left
645 glVertex3f(-1.0, (float)((i+1) - 256/2)/(256/2), 0.0); // top left
646 glVertex3f(-0.9, (float)((i+1) - 256/2)/(256/2), 0.0); // top right
647 glVertex3f(-0.9, (float)((i ) - 256/2)/(256/2), 0.0); // bot right
653 GritsPluginRadar *grits_plugin_radar_new(GritsViewer *viewer, GritsPrefs *prefs)
655 /* TODO: move to constructor if possible */
656 g_debug("GritsPluginRadar: new");
657 GritsPluginRadar *self = g_object_new(GRITS_TYPE_PLUGIN_RADAR, NULL);
658 self->viewer = viewer;
662 GritsCallback *hud_cb = grits_callback_new(_draw_hud, self);
663 self->hud_ref = grits_viewer_add(viewer, GRITS_OBJECT(hud_cb), GRITS_LEVEL_HUD, FALSE);
666 self->conus = radar_conus_new(self->config, self->viewer, self->conus_http);
668 /* Load radar sites */
669 for (city_t *city = cities; city->type; city++) {
670 if (city->type != LOCATION_CITY)
672 RadarSite *site = radar_site_new(city, self->config,
673 self->viewer, self->prefs, self->sites_http);
674 g_hash_table_insert(self->sites, city->code, site);
680 static GtkWidget *grits_plugin_radar_get_config(GritsPlugin *_self)
682 GritsPluginRadar *self = GRITS_PLUGIN_RADAR(_self);
687 static void grits_plugin_radar_plugin_init(GritsPluginInterface *iface);
688 G_DEFINE_TYPE_WITH_CODE(GritsPluginRadar, grits_plugin_radar, G_TYPE_OBJECT,
689 G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN,
690 grits_plugin_radar_plugin_init));
691 static void grits_plugin_radar_plugin_init(GritsPluginInterface *iface)
693 g_debug("GritsPluginRadar: plugin_init");
694 /* Add methods to the interface */
695 iface->get_config = grits_plugin_radar_get_config;
697 static void grits_plugin_radar_init(GritsPluginRadar *self)
699 g_debug("GritsPluginRadar: class_init");
701 self->sites_http = grits_http_new(G_DIR_SEPARATOR_S
702 "nexrad" G_DIR_SEPARATOR_S
703 "level2" G_DIR_SEPARATOR_S);
704 self->conus_http = grits_http_new(G_DIR_SEPARATOR_S
705 "nexrad" G_DIR_SEPARATOR_S
706 "conus" G_DIR_SEPARATOR_S);
707 self->sites = g_hash_table_new_full(g_str_hash, g_str_equal,
708 NULL, (GDestroyNotify)radar_site_free);
709 self->config = gtk_notebook_new();
710 /* Need to position on the top because of Win32 bug */
711 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(self->config), GTK_POS_BOTTOM);
713 static void grits_plugin_radar_dispose(GObject *gobject)
715 g_debug("GritsPluginRadar: dispose");
716 GritsPluginRadar *self = GRITS_PLUGIN_RADAR(gobject);
717 grits_viewer_remove(self->viewer, self->hud_ref);
718 radar_conus_free(self->conus);
719 /* Drop references */
720 G_OBJECT_CLASS(grits_plugin_radar_parent_class)->dispose(gobject);
722 static void grits_plugin_radar_finalize(GObject *gobject)
724 g_debug("GritsPluginRadar: finalize");
725 GritsPluginRadar *self = GRITS_PLUGIN_RADAR(gobject);
727 grits_http_free(self->conus_http);
728 grits_http_free(self->sites_http);
729 g_hash_table_destroy(self->sites);
730 gtk_widget_destroy(self->config);
731 G_OBJECT_CLASS(grits_plugin_radar_parent_class)->finalize(gobject);
734 static void grits_plugin_radar_class_init(GritsPluginRadarClass *klass)
736 g_debug("GritsPluginRadar: class_init");
737 GObjectClass *gobject_class = (GObjectClass*)klass;
738 gobject_class->dispose = grits_plugin_radar_dispose;
739 gobject_class->finalize = grits_plugin_radar_finalize;