static void dist_combo_changed_cb(GtkComboBox* combo, MateWeatherPref* pref) { MateWeatherApplet* gw_applet = pref->priv->applet; DistanceUnit new_unit, old_unit; g_return_if_fail(gw_applet != NULL); new_unit = gtk_combo_box_get_active(combo) + 2; old_unit = gw_applet->mateweather_pref.distance_unit; if (new_unit == old_unit) { return; } gw_applet->mateweather_pref.distance_unit = new_unit; g_settings_set_enum (gw_applet->settings, "distance-unit", new_unit); if (gw_applet->details_dialog) { mateweather_dialog_update(MATEWEATHER_DIALOG(gw_applet->details_dialog)); } }
static void temp_combo_changed_cb(GtkComboBox* combo, MateWeatherPref* pref) { MateWeatherApplet* gw_applet = pref->priv->applet; TempUnit new_unit, old_unit; g_return_if_fail(gw_applet != NULL); new_unit = gtk_combo_box_get_active(combo) + 2; old_unit = gw_applet->mateweather_pref.temperature_unit; if (new_unit == old_unit) { return; } gw_applet->mateweather_pref.temperature_unit = new_unit; g_settings_set_enum (gw_applet->settings, "temperature-unit", new_unit); gtk_label_set_text(GTK_LABEL(gw_applet->label), weather_info_get_temp_summary(gw_applet->mateweather_info)); if (gw_applet->details_dialog) { mateweather_dialog_update(MATEWEATHER_DIALOG(gw_applet->details_dialog)); } }
static void details_cb (GtkAction *action, MateWeatherApplet *gw_applet) { if (gw_applet->details_dialog) { gtk_window_present (GTK_WINDOW (gw_applet->details_dialog)); } else { gw_applet->details_dialog = mateweather_dialog_new(gw_applet); g_object_add_weak_pointer(G_OBJECT(gw_applet->details_dialog), (gpointer *)&(gw_applet->details_dialog)); mateweather_dialog_update (MATEWEATHER_DIALOG (gw_applet->details_dialog)); gtk_widget_show (gw_applet->details_dialog); } }
static void update_finish (WeatherInfo *info, gpointer data) { static int gw_fault_counter = 0; #ifdef HAVE_LIBNOTIFY char *message, *detail; #endif char *s; MateWeatherApplet *gw_applet = (MateWeatherApplet *)data; gint nxtSunEvent; const gchar *icon_name; /* Update timer */ if (gw_applet->timeout_tag > 0) g_source_remove(gw_applet->timeout_tag); if (gw_applet->mateweather_pref.update_enabled) { gw_applet->timeout_tag = g_timeout_add_seconds ( gw_applet->mateweather_pref.update_interval, timeout_cb, gw_applet); nxtSunEvent = weather_info_next_sun_event(gw_applet->mateweather_info); if (nxtSunEvent >= 0) gw_applet->suncalc_timeout_tag = g_timeout_add_seconds (nxtSunEvent, suncalc_timeout_cb, gw_applet); } if ((TRUE == weather_info_is_valid (info)) || (gw_fault_counter >= MAX_CONSECUTIVE_FAULTS)) { gw_fault_counter = 0; icon_name = weather_info_get_icon_name (gw_applet->mateweather_info); gtk_image_set_from_icon_name (GTK_IMAGE(gw_applet->image), icon_name, GTK_ICON_SIZE_BUTTON); gtk_label_set_text (GTK_LABEL (gw_applet->label), weather_info_get_temp_summary( gw_applet->mateweather_info)); s = weather_info_get_weather_summary (gw_applet->mateweather_info); gtk_widget_set_tooltip_text (GTK_WIDGET (gw_applet->applet), s); g_free (s); /* Update dialog -- if one is present */ if (gw_applet->details_dialog) { mateweather_dialog_update (MATEWEATHER_DIALOG (gw_applet->details_dialog)); } /* update applet */ place_widgets(gw_applet); #ifdef HAVE_LIBNOTIFY if (gw_applet->mateweather_pref.show_notifications) { NotifyNotification *n; /* Show notifications if possible */ if (!notify_is_initted ()) notify_init (_("Weather Forecast")); if (notify_is_initted ()) { GError *error = NULL; const char *icon; /* Show notification */ message = g_strdup_printf ("%s: %s", weather_info_get_location_name (info), weather_info_get_sky (info)); detail = g_strdup_printf ( _("City: %s\nSky: %s\nTemperature: %s"), weather_info_get_location_name (info), weather_info_get_sky (info), weather_info_get_temp_summary (info)); icon = weather_info_get_icon_name (gw_applet->mateweather_info); if (icon == NULL) icon = "stock-unknown"; n = notify_notification_new (message, detail, icon); notify_notification_show (n, &error); if (error) { g_warning ("%s", error->message); g_error_free (error); } g_free (message); g_free (detail); } } #endif } else { /* there has been an error during retrival * just update the fault counter */ gw_fault_counter++; } }