static void row_selected_cb(GtkTreeSelection* selection, MateWeatherPref* pref) { MateWeatherApplet* gw_applet = pref->priv->applet; GtkTreeModel* model; WeatherLocation* loc = NULL; GtkTreeIter iter; if (!gtk_tree_selection_get_selected(selection, &model, &iter)) return; gtk_tree_model_get(model, &iter, MATEWEATHER_XML_COL_POINTER, &loc, -1); if (!loc) { return; } g_settings_set_string (gw_applet->settings, "location1", loc->code); g_settings_set_string (gw_applet->settings, "location2", loc->zone); g_settings_set_string (gw_applet->settings, "location3", loc->radar); g_settings_set_string (gw_applet->settings, "location4", loc->name); g_settings_set_string (gw_applet->settings, "coordinates", loc->coordinates); if (gw_applet->mateweather_pref.location) { weather_location_free(gw_applet->mateweather_pref.location); } gw_applet->mateweather_pref.location = weather_location_new (loc->name, loc->code, loc->zone, loc->radar, loc->coordinates, NULL, NULL); mateweather_update(gw_applet); }
static gboolean free_data(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data) { WeatherLocation* location; gtk_tree_model_get(model, iter, MATEWEATHER_XML_COL_POINTER, &location, -1); if (!location) { return FALSE; } weather_location_free(location); return FALSE; }
static gboolean free_locations (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { WeatherLocation *loc = NULL; gtk_tree_model_get (model, iter, MATEWEATHER_XML_COL_POINTER, &loc, -1); if (loc) { weather_location_free (loc); gtk_tree_store_set ((GtkTreeStore *)model, iter, MATEWEATHER_XML_COL_POINTER, NULL, -1); } return FALSE; }
void mateweather_prefs_load (MateWeatherPrefs *prefs, MateWeatherMateConf *ctx) { GError *error = NULL; gchar *mateconf_str = NULL; g_return_if_fail (prefs != NULL); g_return_if_fail (ctx != NULL); if (prefs->location) { weather_location_free (prefs->location); } prefs->location = mateweather_mateconf_get_location (ctx); /* Assume we use unit defaults */ prefs->use_temperature_default = TRUE; prefs->use_speed_default = TRUE; prefs->use_pressure_default = TRUE; prefs->use_distance_default = TRUE; prefs->update_interval = mateweather_mateconf_get_int (ctx, "auto_update_interval", &error); if (error) { g_print ("%s \n", error->message); g_error_free (error); error = NULL; } prefs->update_interval = MAX (prefs->update_interval, 60); prefs->update_enabled = mateweather_mateconf_get_bool (ctx, "auto_update", NULL); prefs->detailed = mateweather_mateconf_get_bool (ctx, "enable_detailed_forecast", NULL); prefs->radar_enabled = mateweather_mateconf_get_bool (ctx, "enable_radar_map", NULL); prefs->use_custom_radar_url = mateweather_mateconf_get_bool (ctx, "use_custom_radar_url", NULL); if (prefs->radar) { g_free (prefs->radar); prefs->radar = NULL; } prefs->radar = mateweather_mateconf_get_string (ctx, "radar", NULL); mateconf_str = mateweather_mateconf_get_string (ctx, MATECONF_TEMP_UNIT, NULL); parse_temp_string (mateconf_str, prefs); g_free (mateconf_str); mateconf_str = mateweather_mateconf_get_string (ctx, MATECONF_SPEED_UNIT, NULL); parse_speed_string (mateconf_str, prefs); g_free (mateconf_str); mateconf_str = mateweather_mateconf_get_string (ctx, MATECONF_PRESSURE_UNIT, NULL); parse_pressure_string (mateconf_str, prefs); g_free (mateconf_str); mateconf_str = mateweather_mateconf_get_string (ctx, MATECONF_DISTANCE_UNIT, NULL); parse_distance_string (mateconf_str, prefs); g_free (mateconf_str); return; }