X-Git-Url: http://pileus.org/git/?p=aweather;a=blobdiff_plain;f=src%2Fplugins%2Fradar.c;h=2dcea83986dc6a0ad45400998a8c0e85d8789b6b;hp=8e5abfc4d1225b8a055c2a1e5723c9b4f97dfd8d;hb=cc82e9478bb47cccb085fb2738053b0c5f6b8298;hpb=85c61bd1f0c45f2de7fee70b209fea4b0d25f6bc diff --git a/src/plugins/radar.c b/src/plugins/radar.c index 8e5abfc..2dcea83 100644 --- a/src/plugins/radar.c +++ b/src/plugins/radar.c @@ -30,7 +30,9 @@ #include "level2.h" #include "../aweather-location.h" -static void _gtk_bin_set_child(GtkBin *bin, GtkWidget *new) +#include "compat.h" + +static void aweather_bin_set_child(GtkBin *bin, GtkWidget *new) { GtkWidget *old = gtk_bin_get_child(bin); if (old) @@ -123,15 +125,16 @@ gboolean _site_update_end(gpointer _site) g_warning("RadarSite: update_end - %s", 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 *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget *msg = gtk_label_new(site->message); GtkWidget *btn = gtk_link_button_new_with_label(uri, "View Radar Status"); + gtk_box_set_homogeneous(GTK_BOX(box), TRUE); 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); + aweather_bin_set_child(GTK_BIN(site->config), box); g_free(uri); } else { - _gtk_bin_set_child(GTK_BIN(site->config), + aweather_bin_set_child(GTK_BIN(site->config), aweather_level2_get_config(site->level2)); } site->status = STATUS_LOADED; @@ -211,7 +214,7 @@ void _site_update(RadarSite *site) /* Add a progress bar */ GtkWidget *progress = gtk_progress_bar_new(); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Loading..."); - _gtk_bin_set_child(GTK_BIN(site->config), progress); + aweather_bin_set_child(GTK_BIN(site->config), progress); /* Remove old volume */ g_debug("RadarSite: update - remove - %s", site->city->code); @@ -296,6 +299,24 @@ void _site_on_location_changed(GritsViewer *viewer, radar_site_unload(site); } +static gboolean on_marker_clicked(GritsObject *marker, GdkEvent *event, RadarSite *site) +{ + GritsViewer *viewer = site->viewer; + GritsPoint center = marker->center; + grits_viewer_set_location(viewer, center.lat, center.lon, EARTH_R/35); + grits_viewer_set_rotation(viewer, 0, 0, 0); + /* Recursivly set notebook tabs */ + GtkWidget *widget, *parent; + for (widget = site->config; widget; widget = parent) { + parent = gtk_widget_get_parent(widget); + if (GTK_IS_NOTEBOOK(parent)) { + gint i = gtk_notebook_page_num(GTK_NOTEBOOK(parent), widget); + gtk_notebook_set_current_page(GTK_NOTEBOOK(parent), i); + } + } + return TRUE; +} + RadarSite *radar_site_new(city_t *city, GtkWidget *pconfig, GritsViewer *viewer, GritsPrefs *prefs, GritsHttp *http) { @@ -321,6 +342,9 @@ RadarSite *radar_site_new(city_t *city, GtkWidget *pconfig, GRITS_OBJECT(site->marker)->lod = EARTH_R*0.75*site->city->lod; grits_viewer_add(site->viewer, GRITS_OBJECT(site->marker), GRITS_LEVEL_HUD, FALSE); + g_signal_connect(site->marker, "clicked", + G_CALLBACK(on_marker_clicked), site); + grits_object_set_cursor(GRITS_OBJECT(site->marker), GDK_HAND2); /* Connect signals */ site->location_id = g_signal_connect(viewer, "location-changed", @@ -450,7 +474,7 @@ gboolean _conus_update_end(gpointer _conus) /* Check error status */ if (conus->message) { g_warning("Conus: update_end - %s", conus->message); - _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new(conus->message)); + aweather_bin_set_child(GTK_BIN(conus->config), gtk_label_new(conus->message)); goto out; } @@ -459,7 +483,7 @@ gboolean _conus_update_end(gpointer _conus) GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(conus->path, &error); if (!pixbuf || error) { g_warning("Conus: update_end - error loading pixbuf: %s", conus->path); - _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new("Error loading pixbuf")); + aweather_bin_set_child(GTK_BIN(conus->config), gtk_label_new("Error loading pixbuf")); g_remove(conus->path); goto out; } @@ -483,7 +507,7 @@ gboolean _conus_update_end(gpointer _conus) /* Update GUI */ gchar *label = g_path_get_basename(conus->path); - _gtk_bin_set_child(GTK_BIN(conus->config), gtk_label_new(label)); + aweather_bin_set_child(GTK_BIN(conus->config), gtk_label_new(label)); grits_viewer_queue_draw(conus->viewer); g_free(label); @@ -558,7 +582,7 @@ void _conus_update(RadarConus *conus) /* Add a progress bar */ GtkWidget *progress = gtk_progress_bar_new(); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), "Loading..."); - _gtk_bin_set_child(GTK_BIN(conus->config), progress); + aweather_bin_set_child(GTK_BIN(conus->config), progress); g_thread_new("conus-update-thread", _conus_update_thread, conus); } @@ -680,7 +704,7 @@ out: } static void _update_hidden(GtkNotebook *notebook, - GtkNotebookPage *page, guint page_num, gpointer viewer) + gpointer _, guint page_num, gpointer viewer) { g_debug("GritsPluginRadar: _update_hidden - 0..%d = %d", gtk_notebook_get_n_pages(notebook), page_num);