]> Pileus Git - aweather/blobdiff - src/plugins/radar.c
Remove deprecated thread functions
[aweather] / src / plugins / radar.c
index 94b18c6cbc613e602ba9d0f75af196b67f5f9733..60e797967eab191f12d9488d5dfcea6432a98a36 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2009-2012 Andy Spencer <andy753421@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -120,8 +120,15 @@ gboolean _site_update_end(gpointer _site)
        RadarSite *site = _site;
        if (site->message) {
                g_warning("RadarSite: update_end - %s", site->message);
-               _gtk_bin_set_child(GTK_BIN(site->config),
-                               gtk_label_new(site->message));
+               const char *fmt = "http://forecast.weather.gov/product.php?site=NWS&product=FTM&format=TXT&issuedby=%s";
+               char       *uri = g_strdup_printf(fmt, site->city->code+1);
+               GtkWidget  *box = gtk_vbox_new(TRUE, 0);
+               GtkWidget  *msg = gtk_label_new(site->message);
+               GtkWidget  *btn = gtk_link_button_new_with_label(uri, "View Radar Status");
+               gtk_box_pack_start(GTK_BOX(box), msg, TRUE, TRUE, 0);
+               gtk_box_pack_start(GTK_BOX(box), btn, TRUE, TRUE, 0);
+               _gtk_bin_set_child(GTK_BIN(site->config), box);
+               g_free(uri);
        } else {
                _gtk_bin_set_child(GTK_BIN(site->config),
                                aweather_level2_get_config(site->level2));
@@ -212,7 +219,7 @@ void _site_update(RadarSite *site)
 
        /* Fork loading right away so updating the
         * list of times doesn't take too long */
-       g_thread_create(_site_update_thread, site, FALSE, NULL);
+       g_thread_new("site-update-thread", _site_update_thread, site);
 }
 
 /* RadarSite methods */
@@ -348,7 +355,7 @@ struct _RadarConus {
        GtkWidget   *config;
        time_t       time;
        const gchar *message;
-       GStaticMutex loading;
+       GMutex       loading;
 
        gchar       *path;
        GritsTile   *tile[2];
@@ -392,10 +399,10 @@ static void _conus_update_end_copy(GritsTile *tile, guchar *pixels)
        tile->coords.w = 1.0/ CONUS_HEIGHT;
        tile->coords.s = tile->coords.n +  CONUS_HEIGHT   / 2048.0;
        tile->coords.e = tile->coords.w + (CONUS_WIDTH/2) / 2048.0;
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glFlush();
        g_free(clear);
 }
@@ -483,7 +490,7 @@ gboolean _conus_update_end(gpointer _conus)
 
 out:
        g_free(conus->path);
-       g_static_mutex_unlock(&conus->loading);
+       g_mutex_unlock(&conus->loading);
        return FALSE;
 }
 
@@ -541,7 +548,7 @@ out:
 
 void _conus_update(RadarConus *conus)
 {
-       if (!g_static_mutex_trylock(&conus->loading))
+       if (!g_mutex_trylock(&conus->loading))
                return;
        conus->time = grits_viewer_get_time(conus->viewer);
        g_debug("Conus: update - %d",
@@ -552,7 +559,7 @@ void _conus_update(RadarConus *conus)
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Loading...");
        _gtk_bin_set_child(GTK_BIN(conus->config), progress);
 
-       g_thread_create(_conus_update_thread, conus, FALSE, NULL);
+       g_thread_new("conus-update-thread", _conus_update_thread, conus);
 }
 
 RadarConus *radar_conus_new(GtkWidget *pconfig,
@@ -562,7 +569,7 @@ RadarConus *radar_conus_new(GtkWidget *pconfig,
        conus->viewer  = g_object_ref(viewer);
        conus->http    = http;
        conus->config  = gtk_alignment_new(0, 0, 1, 1);
-       g_static_mutex_init(&conus->loading);
+       g_mutex_init(&conus->loading);
 
        gdouble south =  CONUS_NORTH - CONUS_DEG_PER_PX*CONUS_HEIGHT;
        gdouble east  =  CONUS_WEST  + CONUS_DEG_PER_PX*CONUS_WIDTH;