[Xfce4-commits] <xfce4-weather-plugin:master> * Start using parsing results. Translation broken, forecast broken.
Colin Leroy
noreply at xfce.org
Wed Nov 16 22:34:04 CET 2011
Updating branch refs/heads/master
to 8fdc23353982a9b6a3c8a2c51d2d6d45be3c1fae (commit)
from ed6d594891ab2d3b3cd0267d99f5f564fc1d5450 (commit)
commit 8fdc23353982a9b6a3c8a2c51d2d6d45be3c1fae
Author: Colin Leroy <colin at colino.net>
Date: Tue Nov 15 22:37:25 2011 +0100
* Start using parsing results.
Translation broken, forecast broken.
panel-plugin/weather-config.c | 15 +-
panel-plugin/weather-data.c | 433 ++++++--------------------------------
panel-plugin/weather-data.h | 127 ++---------
panel-plugin/weather-parsers.c | 28 +++-
panel-plugin/weather-parsers.h | 1 +
panel-plugin/weather-summary.c | 24 ++-
panel-plugin/weather-translate.c | 19 +--
panel-plugin/weather.c | 59 ++----
8 files changed, 160 insertions(+), 546 deletions(-)
diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index e38e822..6027b26 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -34,17 +34,14 @@
#define BORDER 8
static const labeloption labeloptions[OPTIONS_N] = {
- {N_("Windchill (F)"), FLIK},
- {N_("Temperature (T)"), TEMP},
- {N_("Atmosphere pressure (P)"), BAR_R},
- {N_("Atmosphere state (P)"), BAR_D},
+ {N_("Temperature (T)"), TEMPERATURE},
+ {N_("Atmosphere pressure (P)"), PRESSURE},
{N_("Wind speed (WS)"), WIND_SPEED},
- {N_("Wind gust (WG)"), WIND_GUST},
{N_("Wind direction (WD)"), WIND_DIRECTION},
- {N_("Humidity (H)"), HMID},
- {N_("Visibility (V)"), VIS},
- {N_("UV Index (UV)"), UV_INDEX},
- {N_("Dewpoint (DP)"), DEWP},
+ {N_("Humidity (H)"), HUMIDITY},
+ {N_("Cloudiness (C)"), CLOUDINESS},
+ {N_("Fog (F)"), FOG},
+ {N_("Precipitations (R)"), PRECIPITATIONS},
};
typedef void (*cb_function) (xfceweather_data *);
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index 9c36d07..a9c05d9 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -25,376 +25,81 @@
#include "weather-data.h"
#include "weather.h"
-#define DATAS_CC 0x0100
-#define DATAS_LOC 0x0200
-#define DATAS_DAYF 0x0300
-#define DATAS_LNK 0x0400
-
-#define EMPTY_STRING "99"
-#define CHK_NULL(str) (str ? str : EMPTY_STRING);
-
-static const gchar *
-get_data_uv (xml_uv *data,
- datas_uv type)
-{
- gchar *str = NULL;
-
- if (!data)
- {
- DBG ("get_data_bar: xml-uv not present");
- }
- else
- {
- switch (type)
- {
- case _UV_INDEX:
- str = data->i;
- break;
- case _UV_TRANS:
- str = data->t;
- break;
- }
- }
-
- return CHK_NULL (str);
-}
-
-
-
-static const gchar *
-get_data_bar (xml_bar *data,
- datas_bar type)
-{
- gchar *str = NULL;
-
- if (!data)
- {
- DBG ("get_data_bar: xml-wind not present");
- }
- else
- {
- switch (type)
- {
- case _BAR_R:
- str = data->r;
- break;
- case _BAR_D:
- str = data->d;
- break;
- }
- }
-
- return CHK_NULL (str);
-}
-
-
-
-static const gchar *
-get_data_wind (xml_wind *data,
- datas_wind type)
-{
- gchar *str = NULL;
-
- if (!data)
- {
- DBG ("get_data_wind: xml-wind not present");
- }
- else
- {
- switch (type)
- {
- case _WIND_SPEED:
- str = data->s;
- break;
- case _WIND_GUST:
- str = data->gust;
- break;
- case _WIND_DIRECTION:
- str = data->t;
- break;
- case _WIND_TRANS:
- str = data->d;
- break;
- }
- }
-
- return CHK_NULL (str);
-}
-
-
-
-/* -- This is not the same as the previous functions */
-static const gchar *
-get_data_cc (xml_cc *data,
- datas type)
-{
- gchar *str = NULL;
-
- if (!data)
- {
- DBG ("get_data_cc: xml-cc not present");
- }
- else
- {
- switch (type)
- {
- case LSUP:
- str = data->lsup;
- break;
- case OBST:
- str = data->obst;
- break;
- case FLIK:
- str = data->flik;
- break;
- case TRANS:
- str = data->t;
- break;
- case TEMP:
- str = data->tmp;
- break;
- case HMID:
- str = data->hmid;
- break;
- case VIS:
- str = data->vis;
- break;
- case UV_INDEX:
- return get_data_uv (data->uv, _UV_INDEX);
- case UV_TRANS:
- return get_data_uv (data->uv, _UV_TRANS);
- case WIND_SPEED:
- return get_data_wind (data->wind, _WIND_SPEED);
- case WIND_GUST:
- return get_data_wind (data->wind, _WIND_GUST);
- case WIND_DIRECTION:
- return get_data_wind (data->wind, _WIND_DIRECTION);
- case WIND_TRANS:
- return get_data_wind (data->wind, _WIND_TRANS);
- case BAR_R:
- return get_data_bar (data->bar, _BAR_R);
- case BAR_D:
- return get_data_bar (data->bar, _BAR_D);
- case DEWP:
- str = data->dewp;
- break;
- case WICON:
- str = data->icon;
- break;
- }
- }
-
- return CHK_NULL (str);
-}
-
-
-
-static const gchar *
-get_data_loc (xml_loc *data,
- datas_loc type)
-{
- gchar *str = NULL;
-
- if (!data)
- {
- DBG ("get_data_loc: xml-loc not present");
- }
- else
- {
- switch (type)
- {
- case DNAM:
- str = data->dnam;
- break;
- case SUNR:
- str = data->sunr;
- break;
- case SUNS:
- str = data->suns;
- break;
- }
- }
-
- return CHK_NULL (str);
-}
-
-static const gchar *
-get_data_lnk (xml_lnk *data,
- lnks type)
-{
- gchar *str = NULL;
-
- if (!data)
- {
- DBG ("get_data_lnk: xml-lnk not present");
- }
- else
- {
- switch (type)
- {
- case LNK1:
- str = data->lnk[0];
- break;
- case LNK2:
- str = data->lnk[1];
- break;
- case LNK3:
- str = data->lnk[2];
- break;
- case LNK4:
- str = data->lnk[3];
- break;
- case LNK1_TXT:
- str = data->lnk_txt[0];
- break;
- case LNK2_TXT:
- str = data->lnk_txt[1];
- break;
- case LNK3_TXT:
- str = data->lnk_txt[2];
- break;
- case LNK4_TXT:
- str = data->lnk_txt[3];
- break;
- }
- }
-
- return CHK_NULL (str);
-}
-
-
+#define CHK_NULL(s) ((s) ? (s):"")
const gchar *
-get_data (xml_weather *data,
- datas type)
+get_data (xml_weather *data, datas type)
{
- const gchar *str = NULL;
-
- if (data)
- {
-
- switch (type & 0xFF00)
- {
- case DATAS_CC:
- str = get_data_cc (data->cc, type);
- break;
- case DATAS_LOC:
- str = get_data_loc (data->loc, type);
- break;
- case DATAS_LNK:
- str = get_data_lnk (data->lnk, type);
- break;
- default:
- str = EMPTY_STRING;
- }
- }
-
- return CHK_NULL (str);
+ const xml_time *timeslice = NULL;
+ const xml_location *loc = NULL;
+
+ if (data == NULL)
+ return "";
+
+ timeslice = get_current_timeslice(data);
+ if (timeslice == NULL)
+ return "";
+
+ loc = timeslice->location;
+
+ switch(type) {
+ case TEMPERATURE:
+ return CHK_NULL(loc->temperature_value);
+ case PRESSURE:
+ return CHK_NULL(loc->pressure_value);
+ case WIND_SPEED:
+ return CHK_NULL( loc->wind_speed_mps);
+ case WIND_DIRECTION:
+ return CHK_NULL(loc->wind_dir_name);
+ case HUMIDITY:
+ return CHK_NULL(loc->humidity_value);
+ case CLOUDINESS:
+ return CHK_NULL(loc->cloudiness_percent[CLOUDINESS_LOW]);
+ case FOG:
+ return CHK_NULL(loc->fog_percent);
+ case PRECIPITATIONS:
+ return CHK_NULL(loc->precipitation_value);
+ case SYMBOL:
+ return CHK_NULL(loc->symbol);
+ }
+ return "";
}
-
-
-static const gchar *
-get_data_part (xml_part *data,
- forecast type)
-{
- const gchar *str = NULL;
-
- DBG ("now here %s", data->ppcp);
-
- if (data)
- {
- switch (type & 0x000F)
- {
- case F_ICON:
- str = data->icon;
- break;
- case F_TRANS:
- str = data->t;
- break;
- case F_PPCP:
- str = data->ppcp;
- break;
- case F_W_SPEED:
- str = get_data_wind (data->wind, _WIND_SPEED);
- break;
- case F_W_DIRECTION:
- str = get_data_wind (data->wind, _WIND_DIRECTION);
- break;
- }
- }
-
- return CHK_NULL (str);
-}
-
-
-
const gchar *
-get_data_f (xml_dayf *data,
- forecast type)
+get_unit (xml_weather *data, units unit, datas type)
{
- const gchar *str = NULL;
-
- if (data)
- {
- switch (type & 0x0F00)
- {
- case ITEMS:
- switch (type)
- {
- case WDAY:
- str = data->day;
- break;
- case TEMP_MIN:
- str = data->low;
- break;
- case TEMP_MAX:
- str = data->hi;
- break;
- default:
- break;
- }
- break;
- case NPART:
- str = get_data_part (data->part[1], type);
- break;
- case DPART:
- str = get_data_part (data->part[0], type);
- break;
- }
- }
-
- return CHK_NULL (str);
+ const xml_time *timeslice = NULL;
+ const xml_location *loc = NULL;
+
+ if (data == NULL)
+ return "";
+
+ timeslice = get_current_timeslice(data);
+ if (timeslice == NULL)
+ return "";
+
+ loc = timeslice->location;
+
+ switch(type) {
+ case TEMPERATURE:
+ return CHK_NULL(loc->temperature_unit);
+ case PRESSURE:
+ return CHK_NULL(loc->pressure_unit);
+ case WIND_SPEED:
+ return "m/s";
+ case WIND_DIRECTION:
+ return "";
+ case HUMIDITY:
+ return "%";
+ case CLOUDINESS:
+ return "%";
+ case FOG:
+ return "%";
+ case PRECIPITATIONS:
+ return "mm";
+ case SYMBOL:
+ return "";
+ }
+ return "";
}
-
-
-const gchar *
-get_unit (units unit,
- datas type)
-{
- gchar *str;
-
- switch (type & 0x00F0)
- {
- case 0x0020:
- str = (unit == METRIC ? "\302\260C" : "\302\260F");
- break;
- case 0x0030:
- str = "%";
- break;
- case 0x0040:
- str = (unit == METRIC ? _("km/h") : _("mph"));
- break;
- case 0x0050:
- str = (unit == METRIC ? _("hPa") : _("in"));
- break;
- case 0x0060:
- str = (unit == METRIC ? _("km") : _("mi"));
- break;
- default:
- str = "";
- }
-
- return str;
-}
diff --git a/panel-plugin/weather-data.h b/panel-plugin/weather-data.h
index 0fd61c2..1d0b79a 100644
--- a/panel-plugin/weather-data.h
+++ b/panel-plugin/weather-data.h
@@ -20,112 +20,27 @@
G_BEGIN_DECLS
-typedef enum
-{
- _WIND_SPEED,
- _WIND_GUST,
- _WIND_DIRECTION,
- _WIND_TRANS
-}
-datas_wind;
-
-typedef enum
-{
- _BAR_R,
- _BAR_D
-}
-datas_bar;
-
-typedef enum
-{
- _UV_INDEX,
- _UV_TRANS
-}
-datas_uv;
-
-typedef enum
-{
- /* cc */
- LSUP = 0x0101,
- OBST = 0x0102,
- TRANS = 0x0103,
- UV_INDEX = 0x0105,
- UV_TRANS = 0x0106,
- WIND_DIRECTION = 0x0107,
- BAR_D = 0x0108,
- WIND_TRANS = 0x0109,
- WICON = 0x0110,
- FLIK = 0x0120,
- TEMP = 0x0121,
- DEWP = 0x0122,
- HMID = 0x0130,
- WIND_SPEED = 0x0140,
- WIND_GUST = 0x0141,
- BAR_R = 0x0150,
- VIS = 0x0160
-}
-datas;
-
-typedef enum
-{
- DNAM = 0x0201,
- SUNR = 0x0202,
- SUNS = 0x0203
-}
-datas_loc;
-
-typedef enum
-{
- ITEMS = 0x0100,
- WDAY = 0x0101,
- TEMP_MIN = 0x0102,
- TEMP_MAX = 0x0103,
- F_ICON = 0x0001,
- F_PPCP = 0x0002,
- F_W_DIRECTION = 0x0003,
- F_W_SPEED = 0x0004,
- F_TRANS = 0x0005,
- NPART = 0x0200,
- ICON_N = 0x0201,
- PPCP_N = 0x0202,
- W_DIRECTION_N = 0x0203,
- W_SPEED_N = 0x0204,
- TRANS_N = 0x0205,
- DPART = 0x0300,
- ICON_D = 0x0301,
- PPCP_D = 0x0302,
- W_DIRECTION_D = 0x0303,
- W_SPEED_D = 0x0304,
- TRANS_D = 0x0305
-}
-forecast;
-
-typedef enum
-{
- LNK1 = 0x0400,
- LNK2 = 0x0401,
- LNK3 = 0x0402,
- LNK4 = 0x0403,
- LNK1_TXT = 0x0404,
- LNK2_TXT = 0x0405,
- LNK3_TXT = 0x0406,
- LNK4_TXT = 0x0407
-}
-lnks;
-
-typedef enum
-{
- METRIC,
- IMPERIAL
-}
-units;
-
-const gchar *get_data (xml_weather * data, datas type);
-
-const gchar *get_data_f (xml_dayf *, forecast type);
-
-const gchar *get_unit (units unit, datas type);
-
+typedef enum {
+ TEMPERATURE,
+ PRESSURE,
+ WIND_SPEED,
+ WIND_DIRECTION,
+ HUMIDITY,
+ CLOUDINESS,
+ FOG,
+ PRECIPITATIONS,
+ SYMBOL
+} datas;
+
+typedef enum {
+ IMPERIAL,
+ METRIC
+} units;
+
+const gchar *
+get_data (xml_weather *data, datas type);
+const gchar *
+get_unit (xml_weather *data, units unit, datas type);
G_END_DECLS
#endif
diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index eabd255..d7e90ec 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -120,13 +120,23 @@ void parse_time (xmlNode * cur_node, xml_weather * data) {
start_ts = my_timegm(&start_t);
end_ts = my_timegm(&end_t);
+ /* time elements with end == start are the ones with temperatures etc.
+ * They seem to be for each three hours (6 after 4 days).
+ */
+ if (end_ts == start_ts && start_ts > time(NULL) + 4 * 24 * 3600)
+ start_ts -= 6 * 3600;
+ else if (end_ts == start_ts)
+ start_ts -= 3 * 3600;
+
/* split per-hour */
for (cur_ts = start_ts; cur_ts < end_ts; cur_ts += 3600) {
xml_time *timeslice = get_timeslice(data, cur_ts, cur_ts + 3600);
xmlNode *child_node;
- if (!timeslice)
+ if (!timeslice) {
+ g_warning("no timeslice");
return;
+ }
for (child_node = cur_node->children; child_node;
child_node = child_node->next) {
if (NODE_IS_TYPE (child_node, "location")) {
@@ -151,11 +161,27 @@ xml_time *get_timeslice(xml_weather *data, time_t start, time_t end)
return NULL;
data->timeslice[data->num_timeslices] = g_slice_new0(xml_time);
+ data->timeslice[data->num_timeslices]->start = start;
+ data->timeslice[data->num_timeslices]->end = end;
data->num_timeslices++;
return data->timeslice[data->num_timeslices - 1];
}
+xml_time *get_current_timeslice(xml_weather *data)
+{
+ time_t now = time(NULL);
+ int i;
+
+ for (i = 0; i < data->num_timeslices; i++) {
+ if (data->timeslice[i]->start <= now
+ && data->timeslice[i]->end >= now)
+ return data->timeslice[i];
+ }
+
+ return NULL;
+}
+
void parse_location (xmlNode * cur_node, xml_location *loc)
{
xmlNode *child_node;
diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h
index 3f2edc9..3b56da0 100644
--- a/panel-plugin/weather-parsers.h
+++ b/panel-plugin/weather-parsers.h
@@ -85,6 +85,7 @@ void parse_time (xmlNode * cur_node, xml_weather * data);
void parse_location (xmlNode * cur_node, xml_location *location);
xml_time *get_timeslice(xml_weather *data, time_t start, time_t end);
+xml_time *get_current_timeslice(xml_weather *data);
void xml_weather_free (xml_weather * data);
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index b584c7d..1703525 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -265,10 +265,10 @@ create_summary_tab (xfceweather_data *data)
ltag4 = gtk_text_buffer_create_tag(buffer, "lnk4", "foreground-gdk", &lnk_color, NULL);
/* head */
- value = g_strdup_printf (_("Weather report for: %s.\n\n"), get_data (data->weatherdata, DNAM));
+ value = g_strdup_printf (_("Weather report for: %s.\n\n"), data->location_name);
APPEND_BTEXT (value);
g_free (value);
-
+#if 0
date = translate_lsup (get_data (data->weatherdata, LSUP));
value = g_strdup_printf (_("Observation station located in %s\nLast update: %s.\n"),
get_data (data->weatherdata, OBST), date ? date : get_data (data->weatherdata, LSUP));
@@ -350,12 +350,12 @@ create_summary_tab (xfceweather_data *data)
APPEND_LINK_ITEM ("\t", get_data (data->weatherdata, LNK2_TXT), get_data (data->weatherdata, LNK2), ltag2);
APPEND_LINK_ITEM ("\t", get_data (data->weatherdata, LNK3_TXT), get_data (data->weatherdata, LNK3), ltag3);
APPEND_LINK_ITEM ("\t", get_data (data->weatherdata, LNK4_TXT), get_data (data->weatherdata, LNK4), ltag4);
-
+#endif
g_signal_connect(G_OBJECT(view), "motion-notify-event",
G_CALLBACK(view_motion_notify), view);
g_signal_connect(G_OBJECT(view), "leave-notify-event",
G_CALLBACK(view_leave_notify), view);
-
+#if 0
weather_channel_icon = weather_summary_get_logo(data);
if (weather_channel_icon) {
@@ -383,6 +383,7 @@ create_summary_tab (xfceweather_data *data)
g_signal_connect(G_OBJECT(weather_channel_evt), "leave-notify-event",
G_CALLBACK(view_leave_notify), view);
}
+#endif
if (hand_cursor == NULL)
hand_cursor = gdk_cursor_new(GDK_HAND2);
if (text_cursor == NULL)
@@ -393,7 +394,7 @@ create_summary_tab (xfceweather_data *data)
}
static GtkWidget *
-make_forecast (xml_dayf *weatherdata,
+make_forecast (xml_weather *weatherdata,
units unit)
{
GtkWidget *item_vbox, *temp_hbox, *icon_hbox,
@@ -401,9 +402,10 @@ make_forecast (xml_dayf *weatherdata,
GdkPixbuf *icon;
gchar *str, *day, *wind;
+ item_vbox = gtk_vbox_new (FALSE, 0);
+#if 0
DBG ("this day %s", weatherdata->day);
- item_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (item_vbox), 6);
@@ -551,7 +553,7 @@ make_forecast (xml_dayf *weatherdata,
gtk_box_pack_start (GTK_BOX (item_vbox), temp_hbox, FALSE, FALSE, 0);
DBG ("Done");
-
+#endif
return item_vbox;
}
@@ -564,7 +566,7 @@ create_forecast_tab (xfceweather_data *data)
guint i;
gtk_container_set_border_width (GTK_CONTAINER (widg), 6);
-
+#if 0
if (data->weatherdata && data->weatherdata->dayf)
{
for (i = 0; i < XML_WEATHER_DAYF_N - 1; i++)
@@ -586,7 +588,7 @@ create_forecast_tab (xfceweather_data *data)
make_forecast (data->weatherdata->dayf[i], data->unit), FALSE, FALSE,
0);
}
-
+#endif
return widg;
}
@@ -616,7 +618,7 @@ create_summary_window (xfceweather_data *data)
GTK_STOCK_CLOSE,
GTK_RESPONSE_ACCEPT, NULL);
- title = g_strdup_printf (_("Weather report for: %s"), get_data (data->weatherdata, DNAM));
+ title = g_strdup_printf (_("Weather report for: %s"), data->location_name);
xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (window), title);
g_free (title);
@@ -625,7 +627,7 @@ create_summary_window (xfceweather_data *data)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE,
0);
- icon = get_icon (get_data (data->weatherdata, WICON), 48);
+ icon = get_icon (get_data (data->weatherdata, SYMBOL), 48);
if (!icon)
icon = get_icon ("99", 48);
diff --git a/panel-plugin/weather-translate.c b/panel-plugin/weather-translate.c
index bcaf63a..7afb3e2 100644
--- a/panel-plugin/weather-translate.c
+++ b/panel-plugin/weather-translate.c
@@ -449,7 +449,7 @@ translate_wind_speed (const gchar *wspeed,
wspeed_loc = g_strdup (_("N/A"));
else
wspeed_loc =
- g_strdup_printf ("%s %s", wspeed, get_unit (unit, WIND_SPEED));
+ g_strdup_printf ("%s %s", wspeed, get_unit (/* FIXME */NULL, unit, WIND_SPEED));
return wspeed_loc;
}
@@ -490,20 +490,3 @@ translate_time (const gchar *timestr)
return time_loc;
}
-
-
-
-/* Unlimited or a number */
-gchar *
-translate_visibility (const gchar *vis,
- units unit)
-{
- gchar *vis_loc;
-
- if (g_ascii_strcasecmp (vis, "Unlimited") == 0)
- vis_loc = g_strdup (_("Unlimited"));
- else
- vis_loc = g_strdup_printf ("%s %s", vis, get_unit (unit, VIS));
-
- return vis_loc;
-}
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 678536e..2e12f45 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -106,38 +106,29 @@ make_label (xml_weather *weatherdata,
switch (opt)
{
- case VIS:
- lbl = _("V");
+ case TEMPERATURE:
+ lbl = _("T");
+ break;
+ case PRESSURE:
+ lbl = _("P");
break;
- case UV_INDEX:
- lbl = _("U");
+ case WIND_SPEED:
+ lbl = _("WS");
break;
case WIND_DIRECTION:
lbl = _("WD");
break;
- case BAR_D:
- lbl = _("P");
+ case HUMIDITY:
+ lbl = _("H");
break;
- case BAR_R:
- lbl = _("P");
+ case CLOUDINESS:
+ lbl = _("C");
break;
- case FLIK:
+ case FOG:
lbl = _("F");
break;
- case TEMP:
- lbl = _("T");
- break;
- case DEWP:
- lbl = _("D");
- break;
- case HMID:
- lbl = _("H");
- break;
- case WIND_SPEED:
- lbl = _("WS");
- break;
- case WIND_GUST:
- lbl = _("WG");
+ case PRECIPITATIONS:
+ lbl = _("R");
break;
default:
lbl = "?";
@@ -160,19 +151,12 @@ make_label (xml_weather *weatherdata,
switch (opt)
{
- case VIS:
- value = translate_visibility (rawvalue, unit);
- break;
case WIND_DIRECTION:
value = translate_wind_direction (rawvalue);
break;
case WIND_SPEED:
- case WIND_GUST:
value = translate_wind_speed (rawvalue, unit);
break;
- case BAR_D:
- value = g_strdup(translate_bard(rawvalue));
- break;
default:
value = NULL;
break;
@@ -189,7 +173,7 @@ make_label (xml_weather *weatherdata,
else
{
str = g_strdup_printf ("<span size=\"%s\">%s: %s %s</span>",
- txtsize, lbl, rawvalue, get_unit (unit, opt));
+ txtsize, lbl, rawvalue, get_unit (weatherdata, unit, opt));
}
} else {
if (value != NULL)
@@ -201,7 +185,7 @@ make_label (xml_weather *weatherdata,
else
{
str = g_strdup_printf ("<span size=\"%s\">%s %s</span>",
- txtsize, rawvalue, get_unit (unit, opt));
+ txtsize, rawvalue, get_unit (weatherdata, unit, opt));
}
}
return str;
@@ -296,7 +280,7 @@ set_icon_current (xfceweather_data *data)
size = data->size;
}
- icon = get_icon (get_data (data->weatherdata, WICON), size);
+ icon = get_icon (get_data (data->weatherdata, SYMBOL), size);
gtk_image_set_from_pixbuf (GTK_IMAGE (data->iconimage), icon);
@@ -381,6 +365,7 @@ update_weatherdata (xfceweather_data *data)
data->lat, data->lon);
/* start receive thread */
+ g_warning("getting http://api.yr.no/%s", url);
weather_http_receive_data ("api.yr.no", url, data->proxy_host,
data->proxy_port, cb_update, data);
@@ -773,13 +758,13 @@ static gboolean weather_get_tooltip_cb (GtkWidget *widget,
markup_text = g_markup_printf_escaped(
"<b>%s</b>\n"
"%s",
- get_data (data->weatherdata, DNAM),
- translate_desc (get_data (data->weatherdata, TRANS))
+ data->location_name,
+ translate_desc (get_data (data->weatherdata, SYMBOL))
);
gtk_tooltip_set_markup (tooltip, markup_text);
g_free(markup_text);
}
- icon = get_icon (get_data (data->weatherdata, WICON), 32);
+ icon = get_icon (get_data (data->weatherdata, SYMBOL), 32);
gtk_tooltip_set_icon (tooltip, icon);
g_object_unref (G_OBJECT(icon));
@@ -865,7 +850,7 @@ xfceweather_create_control (XfcePanelPlugin *plugin)
xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (mi));
/* assign to tempval because g_array_append_val () is using & operator */
- lbl = TEMP;
+ lbl = TEMPERATURE;
g_array_append_val (data->labels, lbl);
lbl = WIND_DIRECTION;
g_array_append_val (data->labels, lbl);
More information about the Xfce4-commits
mailing list