Commit 8687ba61 authored by Harald Judt's avatar Harald Judt

Make number of forecast days configurable.

Add a spinner button to the configuration dialog and read/write
config entries. The max limit is 10 days, as imposed by the XML
feed.
parent e77af5bf
......@@ -229,6 +229,8 @@ apply_options (xfceweather_dialog *dialog)
data->proxy_host = NULL;
}
data->forecast_days = (gint) gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->spin_forecast_days));
data->animation_transitions = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(dialog->chk_animate_transition));
......@@ -510,6 +512,21 @@ create_config_dialog (xfceweather_data *data,
}
/* number of days shown in forecast */
label = gtk_label_new_with_mnemonic (_("Number of _forecast days:"));
dialog->spin_forecast_days = gtk_spin_button_new_with_range (1, MAX_FORECAST_DAYS, 1);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->spin_forecast_days),
dialog->wd->forecast_days);
gtk_label_set_mnemonic_widget(GTK_LABEL (label),
GTK_WIDGET (dialog->spin_forecast_days));
hbox = gtk_hbox_new (FALSE, BORDER);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), dialog->spin_forecast_days, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_size_group_add_widget (sg, label);
/* labels */
dialog->opt_xmloption = make_label ();
dialog->mdl_xmloption = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
......
......@@ -38,6 +38,7 @@ typedef struct
GtkWidget *txt_proxy_port;
GtkWidget *chk_proxy_use;
GtkWidget *chk_proxy_fromenv;
GtkWidget *spin_forecast_days;
GtkWidget *tooltip_yes;
GtkWidget *tooltip_no;
......
......@@ -406,13 +406,13 @@ make_forecast (xfceweather_data *data)
GdkPixbuf *icon;
GdkColor lightbg = {0, 0xeaea, 0xeaea, 0xeaea};
GdkColor darkbg = {0, 0x6666, 0x6666, 0x6666};
gint num_days = 5, i, weekday, daytime;
gint i, weekday, daytime;
gchar *dayname, *wind_speed, *value, *rawvalue;
xml_time *fcdata;
time_t now_t = time(NULL), fcday_t;
struct tm tm_fcday;
table = gtk_table_new(num_days + 1, 5, FALSE);
table = gtk_table_new(data->forecast_days + 1, 5, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table), 0);
gtk_table_set_col_spacings(GTK_TABLE(table), 0);
gtk_widget_show(GTK_WIDGET(table));
......@@ -438,7 +438,7 @@ make_forecast (xfceweather_data *data)
add_forecast_header(_("Night"), 0.0, &darkbg),
4, 5, 0, 1);
for (i = 0; i < num_days; i++) {
for (i = 0; i < data->forecast_days; i++) {
/* Forecast day headers */
tm_fcday = *localtime(&now_t);
fcday_t = time_calc_day(tm_fcday, i);
......
......@@ -535,6 +535,9 @@ xfceweather_read_config (XfcePanelPlugin *plugin,
data->proxy_port = data->saved_proxy_port;
}
val = xfce_rc_read_int_entry (rc, "forecast_days", 5);
data->forecast_days = (val > 0 && val <= MAX_FORECAST_DAYS) ? val : 5;
data->animation_transitions = xfce_rc_read_bool_entry (rc,
"animation_transitions", TRUE);
......@@ -603,6 +606,8 @@ xfceweather_write_config (XfcePanelPlugin *plugin,
xfce_rc_write_int_entry (rc, "proxy_port", data->proxy_port);
}
xfce_rc_write_int_entry (rc, "forecast_days", data->forecast_days);
xfce_rc_write_bool_entry (rc, "animation_transitions", data->animation_transitions);
for (i = 0; i < data->labels->len; i++)
......
......@@ -23,6 +23,7 @@
#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/panel-plugins/xfce4-weather-plugin"
#define PARTNER_ID "1121946239"
#define LICENSE_KEY "3c4cd39ee5dec84f"
#define MAX_FORECAST_DAYS 10
G_BEGIN_DECLS
......@@ -69,6 +70,7 @@ typedef struct
gint saved_proxy_port;
gboolean animation_transitions;
gint forecast_days;
}
xfceweather_data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment