#include <time.h>
#include <grits.h>
-#include <GL/gl.h>
#include <stdio.h>
#include <string.h>
GritsPoly *poly = grits_poly_parse(sparts[3], "\t", " ", ",");
/* Insert polys into the tree */
- gint id = g_ascii_strtoll(sparts[0], NULL, 10);
+ glong id = g_ascii_strtoll(sparts[0], NULL, 10);
g_tree_insert(counties, (gpointer)id, poly);
/* Insert into states list */
{
GtkWidget *title = gtk_label_new("");
- gchar *title_str = g_markup_printf_escaped(
- "<big><b>%s</b></big>", msg->title);
+ gchar *title_str = g_markup_printf_escaped("<big><b>%s</b></big>",
+ msg->title ?: "No title provided");
gtk_label_set_use_markup(GTK_LABEL(title), TRUE);
gtk_label_set_markup(GTK_LABEL(title), title_str);
gtk_label_set_line_wrap(GTK_LABEL(title), TRUE);
GtkWidget *alert = gtk_scrolled_window_new(NULL, NULL);
GtkWidget *alert_view = gtk_text_view_new();
GtkTextBuffer *alert_buf = gtk_text_buffer_new(NULL);
- gchar *alert_str = g_markup_printf_escaped(
- "%s\n\n%s", msg->description, msg->instruction);
+ gchar *alert_str = g_markup_printf_escaped("%s\n\n%s",
+ msg->description ?: "No description provided",
+ msg->instruction ?: "No instructions provided");
PangoFontDescription *alert_font = pango_font_description_from_string(
"monospace");
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(alert),
gchar **fipses = g_strsplit(msg->cap.fips6, " ", -1);
GList *counties = NULL;
for (int i = 0; fipses[i]; i++) {
- gint fips = g_ascii_strtoll(fipses[i], NULL, 10);
+ glong fips = g_ascii_strtoll(fipses[i], NULL, 10);
GritsPoly *county = g_tree_lookup(alert->counties, (gpointer)fips);
if (!county)
continue;
}
/* Set time widget */
- struct tm tm;
- gmtime_r(&alert->updated, &tm);
+ struct tm *tm = gmtime(&alert->updated);
gchar *date_str = g_strdup_printf(" <b><i>%04d-%02d-%02d %02d:%02d</i></b>",
- tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min);
+ tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min);
gtk_label_set_markup(GTK_LABEL(updated), date_str);
g_free(date_str);
(a->info->prior == b->info->prior) ? 0 : 1;
}
+static gboolean _update_end(gpointer _alert)
+{
+ GritsPluginAlert *alert = _alert;
+ gtk_widget_queue_draw(GTK_WIDGET(alert->viewer));
+ return FALSE;
+}
+
static void _update_warnings(GritsPluginAlert *alert, GList *old)
{
g_debug("GritsPluginAlert: _update_warnings");
}
/* Add new messages */
+ /* Load counties first since it does not require network access */
for (GList *cur = alert->msgs; cur; cur = cur->next) {
AlertMsg *msg = cur->data;
msg->county_based = _load_county_based(alert, msg);
+ }
+ g_idle_add(_update_end, alert);
+ for (GList *cur = alert->msgs; cur; cur = cur->next) {
+ AlertMsg *msg = cur->data;
msg->storm_based = _load_storm_based(alert, msg);
}
+ g_idle_add(_update_end, alert);
g_debug("GritsPluginAlert: _load_warnings - end");
}
g_list_foreach(old, (GFunc)msg_free, NULL);
g_list_free(old);
- gtk_widget_queue_draw(GTK_WIDGET(alert->viewer));
g_debug("GritsPluginAlert: _update - end");
}
{
g_debug("GritsPluginAlert: init");
/* Set defaults */
- alert->threads = g_thread_pool_new(_update, alert, 1, TRUE, NULL);
+ alert->threads = g_thread_pool_new(_update, alert, 1, FALSE, NULL);
alert->config = _make_config();
alert->http = grits_http_new(G_DIR_SEPARATOR_S
"alerts" G_DIR_SEPARATOR_S