+#include "aweather-location.h"
+
+static gint log_levels = 0;
+
+static void log_func(const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer udata)
+{
+ if (log_level & log_levels) {
+ if (log_level == G_LOG_LEVEL_DEBUG)
+ g_fprintf(stderr, "DEBUG: (%p) %s\n",
+ g_thread_self(), message);
+ else
+ g_log_default_handler(log_domain, log_level, message, udata);
+ }
+}
+
+static void on_log_level_changed(GtkSpinButton *spinner, AWeatherGui *self)
+{
+ g_message("main: log_level_changed");
+ gint value = gtk_spin_button_get_value_as_int(spinner);
+ log_levels = (1 << (value+1))-1;
+}
+
+gboolean set_location_time(AWeatherGui *gui, char *site, char *time)
+{
+ /* Set time
+ * Do this before setting setting location
+ * so that it doesn't refresh twice */
+ struct tm tm = {};
+ strptime(time, "%Y-%m-%d %H:%M", &tm);
+ time_t sec = mktime(&tm);
+ if (sec > 0)
+ grits_viewer_set_time(gui->viewer, sec);
+ g_debug("date = [%s] == %lu\n", time, sec);
+
+ /* Set location */
+ for (city_t *city = cities; city->type; city++) {
+ if (city->type == LOCATION_CITY && g_str_equal(city->code, site)) {
+ grits_viewer_set_location(gui->viewer,
+ city->pos.lat, city->pos.lon, EARTH_R/25);
+ break;
+ }
+ }
+ return FALSE;
+}
+