From da276ec7a5189863cef886b80e103e0053a573a4 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sat, 15 Jun 2013 15:27:53 +0200 Subject: API break: remove deprecated constructors and properties for GWeatherInfo Reporting unstructured and untraslated weather forecasts was a hack that we no longer need. We can also remove the world property, as the world location is fixed for the lifetime of the application. --- doc/libgweather-sections.txt | 3 - libgweather/Makefile.am | 5 +- libgweather/gweather-enums.h | 6 -- libgweather/gweather-weather.h | 7 +- libgweather/weather-bom.c | 76 ----------------- libgweather/weather-iwin.c | 125 +++++----------------------- libgweather/weather-met.c | 182 ----------------------------------------- libgweather/weather-priv.h | 5 -- libgweather/weather-yahoo.c | 11 --- libgweather/weather-yrno.c | 6 +- libgweather/weather.c | 100 ++-------------------- 11 files changed, 32 insertions(+), 494 deletions(-) delete mode 100644 libgweather/weather-bom.c delete mode 100644 libgweather/weather-met.c diff --git a/doc/libgweather-sections.txt b/doc/libgweather-sections.txt index ca7c320..1db419b 100644 --- a/doc/libgweather-sections.txt +++ b/doc/libgweather-sections.txt @@ -96,9 +96,7 @@ GWEATHER_TYPE_INFO GWeatherInfoPrivate -GWeatherForecastType gweather_info_new -gweather_info_new_for_world gweather_info_update gweather_info_abort gweather_info_is_valid @@ -134,7 +132,6 @@ gweather_info_get_visibility gweather_info_get_apparent gweather_info_get_sunrise gweather_info_get_sunset -gweather_info_get_forecast gweather_info_get_radar diff --git a/libgweather/Makefile.am b/libgweather/Makefile.am index 93fc6e1..b698c09 100644 --- a/libgweather/Makefile.am +++ b/libgweather/Makefile.am @@ -24,9 +24,8 @@ libgweatherinc_HEADERS = \ libgweather_internal_3_la_SOURCES = \ weather.c weather-priv.h \ - weather-metar.c weather-iwin.c weather-met.c \ - weather-bom.c weather-yahoo.c weather-wx.c \ - weather-yrno.c \ + weather-metar.c weather-iwin.c weather-wx.c \ + weather-yahoo.c weather-yrno.c \ weather-sun.c weather-moon.c \ gweather-enum-types.c \ gweather-location.c gweather-location.h \ diff --git a/libgweather/gweather-enums.h b/libgweather/gweather-enums.h index 1191cd6..57a34e1 100644 --- a/libgweather/gweather-enums.h +++ b/libgweather/gweather-enums.h @@ -21,12 +21,6 @@ #ifndef __GWEATHER_ENUMS_H_ #define __GWEATHER_ENUMS_H_ -typedef enum { /*< underscore_name=gweather_forecast_type >*/ - GWEATHER_FORECAST_STATE, - GWEATHER_FORECAST_ZONE, - GWEATHER_FORECAST_LIST -} GWeatherForecastType; - typedef enum { /*< underscore_name=gweather_temperature_unit >*/ GWEATHER_TEMP_UNIT_INVALID = 0, GWEATHER_TEMP_UNIT_DEFAULT, diff --git a/libgweather/gweather-weather.h b/libgweather/gweather-weather.h index 86c1f29..3c2e10a 100644 --- a/libgweather/gweather-weather.h +++ b/libgweather/gweather-weather.h @@ -75,11 +75,7 @@ struct _GWeatherInfoClass { }; GType gweather_info_get_type (void) G_GNUC_CONST; -GWeatherInfo * gweather_info_new (GWeatherLocation *location, - GWeatherForecastType forecast_type); -GWeatherInfo * gweather_info_new_for_world (GWeatherLocation *world, - GWeatherLocation *location, - GWeatherForecastType forecast_type); +GWeatherInfo * gweather_info_new (GWeatherLocation *location); void gweather_info_update (GWeatherInfo *info); void gweather_info_abort (GWeatherInfo *info); void gweather_info_store_cache (void); @@ -109,7 +105,6 @@ gchar * gweather_info_get_visibility (GWeatherInfo *info); gchar * gweather_info_get_apparent (GWeatherInfo *info); gchar * gweather_info_get_sunrise (GWeatherInfo *info); gchar * gweather_info_get_sunset (GWeatherInfo *info); -gchar * gweather_info_get_forecast (GWeatherInfo *info); GSList * gweather_info_get_forecast_list (GWeatherInfo *info); GdkPixbufAnimation * gweather_info_get_radar (GWeatherInfo *info); const gchar *gweather_info_get_attribution (GWeatherInfo *info); diff --git a/libgweather/weather-bom.c b/libgweather/weather-bom.c deleted file mode 100644 index 11ac80a..0000000 --- a/libgweather/weather-bom.c +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* weather-bom.c - Australian Bureau of Meteorology forecast source - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - * . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE -#include "weather-priv.h" - -static void -bom_finish (SoupSession *session, SoupMessage *msg, gpointer data) -{ - GWeatherInfo *info = (GWeatherInfo *)data; - char *p, *rp; - - g_return_if_fail (info != NULL); - - if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { - g_warning ("Failed to get BOM forecast data: %d %s.\n", - msg->status_code, msg->reason_phrase); - _gweather_info_request_done (info); - return; - } - - p = strstr (msg->response_body->data, "Forecast for the rest"); - if (p != NULL) { - rp = strstr (p, "The next routine forecast will be issued"); - if (rp == NULL) - info->priv->forecast = g_strdup (p); - else - info->priv->forecast = g_strndup (p, rp - p); - } - - if (info->priv->forecast == NULL) - info->priv->forecast = g_strdup (msg->response_body->data); - - g_print ("%s\n", info->priv->forecast); - _gweather_info_request_done (info); -} - -void -bom_start_open (GWeatherInfo *info) -{ - gchar *url; - SoupMessage *msg; - WeatherLocation *loc; - - loc = &info->priv->location; - - url = g_strdup_printf ("http://www.bom.gov.au/fwo/%s.txt", - loc->zone + 1); - - msg = soup_message_new ("GET", url); - soup_session_queue_message (info->priv->session, msg, bom_finish, info); - g_free (url); - - info->priv->requests_pending++; -} diff --git a/libgweather/weather-iwin.c b/libgweather/weather-iwin.c index eb55939..5961878 100644 --- a/libgweather/weather-iwin.c +++ b/libgweather/weather-iwin.c @@ -29,47 +29,6 @@ #define GWEATHER_I_KNOW_THIS_IS_UNSTABLE #include "weather-priv.h" -/* - * Humans don't deal well with .MONDAY...SUNNY AND BLAH BLAH.TUESDAY...THEN THIS AND THAT.WEDNESDAY...RAINY BLAH BLAH. - * This function makes it easier to read. - */ -static gchar * -formatWeatherMsg (gchar *forecast) -{ - gchar *ptr = forecast; - gchar *startLine = NULL; - - while (0 != *ptr) { - if (ptr[0] == '\n' && ptr[1] == '.') { - /* This removes the preamble by shifting the relevant data - * down to the start of the buffer. */ - if (NULL == startLine) { - memmove (forecast, ptr, strlen (ptr) + 1); - ptr = forecast; - ptr[0] = ' '; - } - ptr[1] = '\n'; - ptr += 2; - startLine = ptr; - } else if (ptr[0] == '.' && ptr[1] == '.' && ptr[2] == '.' && NULL != startLine) { - memmove (startLine + 2, startLine, (ptr - startLine) * sizeof (gchar)); - startLine[0] = ' '; - startLine[1] = '\n'; - ptr[2] = '\n'; - - ptr += 3; - - } else if (ptr[0] == '$' && ptr[1] == '$') { - ptr[0] = ptr[1] = ' '; - - } else { - ptr++; - } - } - - return forecast; -} - static gboolean hasAttr (xmlNode *node, const char *attr_name, const char *attr_value) { @@ -279,8 +238,6 @@ parseForecastXml (const char *buff, GWeatherInfo *master_info) }; priv->valid = TRUE; - g_free (priv->forecast); - priv->forecast = g_strdup ((const char *)val); for (i = 0; i < G_N_ELEMENTS (ph_list); i++) { if (strstr ((const char *)val, ph_list [i].name)) { @@ -372,11 +329,7 @@ iwin_finish (SoupSession *session, SoupMessage *msg, gpointer data) } priv = info->priv; - - if (priv->forecast_type == GWEATHER_FORECAST_LIST) - priv->forecast_list = parseForecastXml (msg->response_body->data, info); - else - priv->forecast = formatWeatherMsg (g_strdup (msg->response_body->data)); + priv->forecast_list = parseForecastXml (msg->response_body->data, info); _gweather_info_request_done (info); } @@ -386,81 +339,41 @@ gboolean iwin_start_open (GWeatherInfo *info) { GWeatherInfoPrivate *priv; - gchar *url, *state, *zone; + gchar *url; WeatherLocation *loc; SoupMessage *msg; - g_return_val_if_fail (info != NULL, FALSE); + g_assert (info != NULL); priv = info->priv; loc = &priv->location; - g_return_val_if_fail (loc != NULL, FALSE); - /* No zone (or -) means no weather information from national offices */ - if ((!loc->zone || loc->zone[0] == '-')) + /* No zone (or -) means no weather information from national offices. + We don't actually use zone, but it's a good indicator of a US location. + (@ and : prefixes were used in the past for Australia and UK) */ + if (!loc->zone || loc->zone[0] == '-' || loc->zone[0] == '@' || loc->zone[0] == ':') return FALSE; - /* Zones starting with : are for the UK Met Office, @ is for Austrialian - Bureau of Metereology. GWEATHER_FORECAST_LIST only works for US, so bail - out early if the location is outside. - */ - if (priv->forecast_type == GWEATHER_FORECAST_LIST && - (loc->zone[0] == ':' || loc->zone[0] == '@')) + if (!loc->latlon_valid) return FALSE; - /* We also need a pair of coordinates for GWEATHER_FORECAST_LIST */ - if (priv->forecast_type == GWEATHER_FORECAST_LIST && - !loc->latlon_valid) - return FALSE; - - if (priv->forecast_type == GWEATHER_FORECAST_LIST) { - /* see the description here: http://www.weather.gov/forecasts/xml/ */ - struct tm tm; - time_t now; - gchar latstr[G_ASCII_DTOSTR_BUF_SIZE], lonstr[G_ASCII_DTOSTR_BUF_SIZE]; - - now = time (NULL); - localtime_r (&now, &tm); - - g_ascii_dtostr (latstr, sizeof(latstr), RADIANS_TO_DEGREES (loc->latitude)); - g_ascii_dtostr (lonstr, sizeof(lonstr), RADIANS_TO_DEGREES (loc->longitude)); - url = g_strdup_printf ("http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?&lat=%s&lon=%s&format=24+hourly&startDate=%04d-%02d-%02d&numDays=7", - latstr, lonstr, 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday); - msg = soup_message_new ("GET", url); - g_free (url); - soup_session_queue_message (priv->session, msg, iwin_finish, info); - - priv->requests_pending++; - return TRUE; - } - - if (loc->zone[0] == ':') { - /* Met Office Region Names */ - metoffice_start_open (info); - return TRUE; - } else if (loc->zone[0] == '@') { - /* Australian BOM forecasts */ - bom_start_open (info); - return TRUE; - } - - /* The zone for Pittsburgh (for example) is given as PAZ021 in the locations - ** file (the PA stands for the state pennsylvania). The url used wants the state - ** as pa, and the zone as lower case paz021. - */ - zone = g_ascii_strdown (loc->zone, -1); - state = g_strndup (zone, 2); + /* see the description here: http://www.weather.gov/forecasts/xml/ */ + struct tm tm; + time_t now; + gchar latstr[G_ASCII_DTOSTR_BUF_SIZE], lonstr[G_ASCII_DTOSTR_BUF_SIZE]; - url = g_strdup_printf ("http://weather.noaa.gov/pub/data/forecasts/zone/%s/%s.txt", state, zone); + now = time (NULL); + localtime_r (&now, &tm); - g_free (zone); - g_free (state); - + g_ascii_dtostr (latstr, sizeof(latstr), RADIANS_TO_DEGREES (loc->latitude)); + g_ascii_dtostr (lonstr, sizeof(lonstr), RADIANS_TO_DEGREES (loc->longitude)); + url = g_strdup_printf ("http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?&lat=%s&lon=%s&format=24+hourly&startDate=%04d-%02d-%02d&numDays=7", + latstr, lonstr, 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday); msg = soup_message_new ("GET", url); - g_free (url); soup_session_queue_message (priv->session, msg, iwin_finish, info); priv->requests_pending++; + g_free (url); return TRUE; } diff --git a/libgweather/weather-met.c b/libgweather/weather-met.c deleted file mode 100644 index 281c384..0000000 --- a/libgweather/weather-met.c +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* weather-met.c - UK Met Office forecast source - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - * . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE -#include "weather-priv.h" - -static char * -met_reprocess (char *x, int len) -{ - char *p = x; - char *o; - int spacing = 0; - static gchar *buf; - static gint buflen = 0; - gchar *lastspace = NULL; - int count = 0; - - if (buflen < len) - { - if (buf) - g_free (buf); - buf = g_malloc (len + 1); - buflen = len; - } - - o = buf; - x += len; /* End mark */ - - while (*p && p < x) { - if (g_ascii_isspace (*p)) { - if (!spacing) { - spacing = 1; - lastspace = o; - count++; - *o++ = ' '; - } - p++; - continue; - } - spacing = 0; - if (count > 75 && lastspace) { - count = o - lastspace - 1; - *lastspace = '\n'; - lastspace = NULL; - } - - if (*p == '&') { - if (g_ascii_strncasecmp (p, "&", 5) == 0) { - *o++ = '&'; - count++; - p += 5; - continue; - } - if (g_ascii_strncasecmp (p, "<", 4) == 0) { - *o++ = '<'; - count++; - p += 4; - continue; - } - if (g_ascii_strncasecmp (p, ">", 4) == 0) { - *o++ = '>'; - count++; - p += 4; - continue; - } - } - if (*p == '<') { - if (g_ascii_strncasecmp (p, "

", 4) == 0) { - *o++ = '\n'; - count = 0; - } - if (g_ascii_strncasecmp (p, "

", 4) == 0) { - *o++ = '\n'; - count = 0; - } - if (g_ascii_strncasecmp (p, "

", 5) == 0) { - *o++ = '\n'; - *o++ = '\n'; - count = 0; - } - p++; - while (*p && *p != '>') - p++; - if (*p) - p++; - continue; - } - *o++ = *p++; - count++; - } - *o = 0; - return buf; -} - - -/* - * Parse the metoffice forecast info. - * For gnome 3.0 we want to just embed an HTML bonobo component and - * be done with this ;) - */ - -static gchar * -met_parse (const gchar *meto) -{ - gchar *p; - gchar *rp; - gchar *r = g_strdup ("Met Office Forecast\n\n"); - gchar *t; - - g_return_val_if_fail (meto != NULL, r); - - p = strstr (meto, "Headline:"); - g_return_val_if_fail (p != NULL, r); - - rp = strstr (p, "status_code)) { - g_warning ("Failed to get Met Office forecast data: %d %s.\n", - msg->status_code, msg->reason_phrase); - _gweather_info_request_done (info); - return; - } - - info->priv->forecast = met_parse (msg->response_body->data); - _gweather_info_request_done (info); -} - -void -metoffice_start_open (GWeatherInfo *info) -{ - gchar *url; - SoupMessage *msg; - WeatherLocation *loc; - - loc = &info->priv->location; - url = g_strdup_printf ("http://www.metoffice.gov.uk/weather/uk/%s/%s_forecast_weather_noscript.html", loc->zone + 1, loc->zone + 1); - - msg = soup_message_new ("GET", url); - soup_session_queue_message (info->priv->session, msg, met_finish, info); - g_free (url); - - info->priv->requests_pending++; -} diff --git a/libgweather/weather-priv.h b/libgweather/weather-priv.h index 7ffd171..784fec8 100644 --- a/libgweather/weather-priv.h +++ b/libgweather/weather-priv.h @@ -90,7 +90,6 @@ typedef gdouble GWeatherVisibility; typedef time_t GWeatherUpdate; struct _GWeatherInfoPrivate { - GWeatherForecastType forecast_type; GWeatherProvider providers; GSettings *settings; @@ -104,7 +103,6 @@ struct _GWeatherInfoPrivate { gboolean moonValid; gboolean tempMinMaxValid; WeatherLocation location; - GWeatherLocation *world; GWeatherLocation *glocation; GWeatherUpdate update; GWeatherUpdate current_time; @@ -122,7 +120,6 @@ struct _GWeatherInfoPrivate { GWeatherUpdate sunset; GWeatherMoonPhase moonphase; GWeatherMoonLatitude moonlatitude; - gchar *forecast; GSList *forecast_list; /* list of GWeatherInfo* for the forecast, NULL if not available */ gchar *forecast_attribution; gchar *radar_buffer; @@ -179,8 +176,6 @@ struct _GWeatherInfoPrivate { void metar_start_open (GWeatherInfo *info); gboolean iwin_start_open (GWeatherInfo *info); -void metoffice_start_open (GWeatherInfo *info); -void bom_start_open (GWeatherInfo *info); void wx_start_open (GWeatherInfo *info); gboolean yahoo_start_open (GWeatherInfo *info); gboolean yrno_start_open (GWeatherInfo *info); diff --git a/libgweather/weather-yahoo.c b/libgweather/weather-yahoo.c index 98401ed..778169e 100644 --- a/libgweather/weather-yahoo.c +++ b/libgweather/weather-yahoo.c @@ -188,10 +188,6 @@ make_info_from_node (GWeatherInfo *master_info, priv->tempMinMaxValid = priv->tempMinMaxValid || (priv->temp_max > -999.0 && priv->temp_min > -999.0); priv->valid = priv->tempMinMaxValid; - val = xmlGetProp (node, XC("text")); - priv->forecast = g_strdup ((const char*) val); - xmlFree (val); - val = xmlGetProp (node, XC("code")); code = strtol((const char*) val, NULL, 0); if (code >= 0 && code < G_N_ELEMENTS (condition_codes)) { @@ -277,13 +273,6 @@ yahoo_start_open (GWeatherInfo *info) if (!loc->yahoo_id) return FALSE; - /* Yahoo! Weather only supports forecast list - (and really, the other types only make sense with national - weather offices that cannot return structured data) - */ - if (!priv->forecast_type != GWEATHER_FORECAST_LIST) - return FALSE; - /* u=f means that the values are in imperial system (which is what weather.c expects). They're converted to user preferences before displaying. diff --git a/libgweather/weather-yrno.c b/libgweather/weather-yrno.c index ec61af2..6f07e16 100644 --- a/libgweather/weather-yrno.c +++ b/libgweather/weather-yrno.c @@ -482,9 +482,6 @@ yrno_start_open_old (GWeatherInfo *info) priv = info->priv; - if (priv->forecast_type != GWEATHER_FORECAST_LIST) - return FALSE; - url = build_yrno_url_geonames (priv->glocation, "forecast.xml"); if (url == NULL) return FALSE; @@ -531,8 +528,7 @@ yrno_start_open_new (GWeatherInfo *info) priv = info->priv; loc = &priv->location; - if (!loc->latlon_valid || - priv->forecast_type != GWEATHER_FORECAST_LIST) + if (!loc->latlon_valid) return FALSE; /* see the description here: http://api.yr.no/weatherapi/ */ diff --git a/libgweather/weather.c b/libgweather/weather.c index dc63bc9..4c6782b 100644 --- a/libgweather/weather.c +++ b/libgweather/weather.c @@ -64,9 +64,7 @@ enum { PROP_0, - PROP_WORLD, PROP_LOCATION, - PROP_TYPE, PROP_ENABLED_PROVIDERS, PROP_LAST }; @@ -359,9 +357,6 @@ gweather_info_reset (GWeatherInfo *info) { GWeatherInfoPrivate *priv = info->priv; - g_free (priv->forecast); - priv->forecast = NULL; - g_free (priv->forecast_attribution); priv->forecast_attribution = NULL; @@ -394,7 +389,6 @@ gweather_info_reset (GWeatherInfo *info) priv->sunset = 0; priv->moonphase = 0; priv->moonlatitude = 0; - priv->forecast = NULL; priv->forecast_list = NULL; priv->radar = NULL; } @@ -421,6 +415,7 @@ gweather_info_init (GWeatherInfo *info) priv = info->priv = G_TYPE_INSTANCE_GET_PRIVATE (info, GWEATHER_TYPE_INFO, GWeatherInfoPrivate); + priv->providers = GWEATHER_PROVIDER_METAR | GWEATHER_PROVIDER_IWIN; priv->settings = g_settings_new ("org.gnome.GWeather"); g_signal_connect_object (priv->settings, "changed", @@ -592,12 +587,6 @@ gweather_info_finalize (GObject *object) if (priv->glocation) gweather_location_unref (priv->glocation); - if (priv->world) - gweather_location_unref (priv->world); - - g_free (priv->forecast); - priv->forecast = NULL; - g_free (priv->radar_url); priv->radar_url = NULL; @@ -1092,13 +1081,6 @@ gweather_info_get_sunset (GWeatherInfo *info) return buf; } -gchar * -gweather_info_get_forecast (GWeatherInfo *info) -{ - g_return_val_if_fail (GWEATHER_IS_INFO (info), NULL); - return g_strdup (info->priv->forecast); -} - /** * gweather_info_get_forecast_list: * @info: a #GWeatherInfo @@ -2006,6 +1988,8 @@ gweather_info_set_location_internal (GWeatherInfo *info, * @location: (allow-none): a location for which weather is desired * * Changes @info to report weather for @location. + * Note that this will clear any forecast or current conditions from + * @info, you must call gweather_info_update() to obtain the new data. */ void gweather_info_set_location (GWeatherInfo *info, @@ -2014,7 +1998,7 @@ gweather_info_set_location (GWeatherInfo *info, g_return_if_fail (GWEATHER_IS_INFO (info)); gweather_info_set_location_internal (info, location); - gweather_info_update (info); + gweather_info_reset (info); } GWeatherProvider @@ -2050,22 +2034,14 @@ gweather_info_set_property (GObject *object, GParamSpec *pspec) { GWeatherInfo *self = GWEATHER_INFO (object); - GWeatherInfoPrivate *priv = self->priv; switch (property_id) { - case PROP_WORLD: - priv->world = g_value_dup_boxed (value); - break; case PROP_LOCATION: gweather_info_set_location_internal (self, (GWeatherLocation*) g_value_get_boxed (value)); break; - case PROP_TYPE: - priv->forecast_type = g_value_get_enum (value); - break; case PROP_ENABLED_PROVIDERS: gweather_info_set_enabled_providers (self, g_value_get_flags (value)); break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -2081,15 +2057,9 @@ gweather_info_get_property (GObject *object, GWeatherInfoPrivate *priv = self->priv; switch (property_id) { - case PROP_WORLD: - g_value_set_boxed (value, priv->world); - break; case PROP_LOCATION: g_value_set_boxed (value, priv->glocation); break; - case PROP_TYPE: - g_value_set_enum (value, priv->forecast_type); - break; case PROP_ENABLED_PROVIDERS: g_value_set_flags (value, priv->providers); break; @@ -2110,13 +2080,6 @@ gweather_info_class_init (GWeatherInfoClass *klass) gobject_class->set_property = gweather_info_set_property; gobject_class->get_property = gweather_info_get_property; - pspec = g_param_spec_boxed ("world", - "World", - "The hierarchy of locations containing the desired location", - GWEATHER_TYPE_LOCATION, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_DEPRECATED); - g_object_class_install_property (gobject_class, PROP_WORLD, pspec); - pspec = g_param_spec_boxed ("location", "Location", "The location this info represents", @@ -2124,14 +2087,6 @@ gweather_info_class_init (GWeatherInfoClass *klass) G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property (gobject_class, PROP_LOCATION, pspec); - pspec = g_param_spec_enum ("forecast-type", - "Forecast type", - "The type of forecast desired (list, zone or state)", - GWEATHER_TYPE_FORECAST_TYPE, - GWEATHER_FORECAST_LIST, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (gobject_class, PROP_TYPE, pspec); - pspec = g_param_spec_flags ("enabled-providers", "Enabled providers", "A bitmask of enabled weather service providers", @@ -2160,59 +2115,22 @@ gweather_info_class_init (GWeatherInfoClass *klass) /** * gweather_info_new: - * @location: (allow-none): the desidered #GWeatherLocation (NULL for default) - * @forecast_type: the type of forecast requested + * @location: (allow-none): the desidered #GWeatherLocation (%NULL for default) * * Builds a new #GWeatherInfo that will provide weather information about * @location. - * Note that, as compared to g_object_new(), this will call gweather_info_update() - * on the resulting info, which will not be ready until the #GWeatherInfo::updated - * signal is emitted. * * Returns: (transfer full): a new #GWeatherInfo */ GWeatherInfo * -gweather_info_new (GWeatherLocation *location, - GWeatherForecastType forecast_type) -{ - GWeatherInfo *self; - - if (location != NULL) - self = g_object_new (GWEATHER_TYPE_INFO, "location", location, "forecast-type", forecast_type, NULL); - else - self = g_object_new (GWEATHER_TYPE_INFO, "forecast-type", forecast_type, NULL); - gweather_info_update (self); - - return self; -} - -/** - * gweather_info_new_for_world: - * @world: a #GWeatherLocation representing the whole world - * @location: (allow-none): the desidered #GWeatherLocation (NULL for default) - * @forecast_type: the type of forecast requested - * - * Similar to gweather_info_new(), but also has a @world parameter, that allow controlling - * the hierarchy of #GWeatherLocation to which @location (or the default one taken from - * GSettings) belongs. - * - * Returns: (transfer full): a new #GWeatherInfo - * - * Deprecated: there is only one world-level #GWeatherLocation at any time, so - * this is the same as gweather_info_new(). - */ -GWeatherInfo * -gweather_info_new_for_world (GWeatherLocation *world, - GWeatherLocation *location, - GWeatherForecastType forecast_type) +gweather_info_new (GWeatherLocation *location) { GWeatherInfo *self; if (location != NULL) - self = g_object_new (GWEATHER_TYPE_INFO, "world", world, "location", location, "forecast-type", forecast_type, NULL); + self = g_object_new (GWEATHER_TYPE_INFO, "location", location, NULL); else - self = g_object_new (GWEATHER_TYPE_INFO, "world", world, "forecast-type", forecast_type, NULL); - gweather_info_update (self); + self = g_object_new (GWEATHER_TYPE_INFO, NULL); return self; } @@ -2220,5 +2138,5 @@ gweather_info_new_for_world (GWeatherLocation *world, GWeatherInfo * _gweather_info_new_clone (GWeatherInfo *other) { - return g_object_new (GWEATHER_TYPE_INFO, "location", other->priv->glocation, "forecast-type", other->priv->forecast_type, NULL); + return g_object_new (GWEATHER_TYPE_INFO, "location", other->priv->glocation, NULL); } -- cgit v1.2.1