[Xfce4-commits] <xfce4-weather-plugin:master> Handle events for show/hide scrollbox and scrollbox lines.
Harald Judt
noreply at xfce.org
Tue Nov 27 16:46:20 CET 2012
Updating branch refs/heads/master
to 69440915aa431f3f905eb8d7c60ef1a9bb8d642e (commit)
from efe7ceac96868e3b0ec6d5a4d36166ccc765fed9 (commit)
commit 69440915aa431f3f905eb8d7c60ef1a9bb8d642e
Author: Harald Judt <h.judt at gmx.at>
Date: Sat Nov 24 11:57:34 2012 +0100
Handle events for show/hide scrollbox and scrollbox lines.
panel-plugin/weather-config.c | 32 +++++++++++++++++++++++++++++++-
panel-plugin/weather.c | 12 ++++++++++++
panel-plugin/weather.h | 9 ++++++---
3 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 22049ca..7d5417d 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -921,6 +921,26 @@ create_appearance_page(xfceweather_dialog *dialog)
}
+static void
+check_scrollbox_show_toggled(GtkWidget *button,
+ gpointer user_data)
+{
+ xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+ dialog->wd->show_scrollbox =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+}
+
+
+static void
+spin_scrollbox_lines_value_changed(const GtkWidget *spin,
+ gpointer user_data)
+{
+ xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+ dialog->wd->scrollbox_lines =
+ (guint) gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
+}
+
+
static GtkWidget *
create_scrollbox_page(xfceweather_dialog *dialog)
{
@@ -943,13 +963,23 @@ create_scrollbox_page(xfceweather_dialog *dialog)
gtk_check_button_new_with_mnemonic("Show scroll_box");
gtk_box_pack_start(GTK_BOX(hbox), dialog->check_scrollbox_show,
TRUE, TRUE, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
+ (dialog->check_scrollbox_show),
+ dialog->wd->show_scrollbox);
+ g_signal_connect(dialog->check_scrollbox_show, "toggled",
+ G_CALLBACK(check_scrollbox_show_toggled), dialog);
/* values to show at once (multiple lines) */
label = gtk_label_new_with_mnemonic(_("L_ines:"));
gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
- ADD_SPIN(dialog->spin_scrollbox_lines, 1, 6, 1, 1, 0, sg_misc);
+ ADD_SPIN(dialog->spin_scrollbox_lines, 1, MAX_SCROLLBOX_LINES, 1,
+ dialog->wd->scrollbox_lines, 0, sg_misc);
gtk_box_pack_start(GTK_BOX(page), hbox, FALSE, FALSE, 0);
+ g_signal_connect(GTK_SPIN_BUTTON(dialog->spin_scrollbox_lines),
+ "value-changed",
+ G_CALLBACK(spin_scrollbox_lines_value_changed),
+ dialog);
/* font and color */
hbox = gtk_hbox_new(FALSE, BORDER);
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 26e0d8c..75f354e 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -553,6 +553,13 @@ xfceweather_read_config(XfcePanelPlugin *plugin,
icon_theme_free(data->icon_theme);
data->icon_theme = icon_theme_load(value);
+ data->show_scrollbox = xfce_rc_read_bool_entry(rc, "show_scrollbox", TRUE);
+
+ data->scrollbox_lines = xfce_rc_read_int_entry(rc, "scrollbox_lines", 1);
+ if (data->scrollbox_lines < 1 ||
+ data->scrollbox_lines > MAX_SCROLLBOX_LINES)
+ data->scrollbox_lines = 1;
+
data->labels = labels_clear(data->labels);
val = 0;
while (val != -1) {
@@ -619,6 +626,11 @@ xfceweather_write_config(XfcePanelPlugin *plugin,
if (data->icon_theme && data->icon_theme->dir)
xfce_rc_write_entry(rc, "theme_dir", data->icon_theme->dir);
+ xfce_rc_write_bool_entry(rc, "show_scrollbox",
+ data->show_scrollbox);
+
+ xfce_rc_write_int_entry(rc, "scrollbox_lines", data->scrollbox_lines);
+
for (i = 0; i < data->labels->len; i++) {
g_snprintf(label, 10, "label%d", i);
xfce_rc_write_int_entry(rc, label,
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index f40478a..3cdf4e0 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -27,6 +27,7 @@
#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/panel-plugins/xfce4-weather-plugin"
#define MAX_FORECAST_DAYS 10
#define DEFAULT_FORECAST_DAYS 5
+#define MAX_SCROLLBOX_LINES 6
G_BEGIN_DECLS
@@ -38,14 +39,11 @@ typedef struct {
GtkWidget *top_vbox;
GtkWidget *top_hbox;
GtkWidget *vbox_center_scrollbox;
- GtkWidget *scrollbox;
GtkWidget *iconimage;
GtkWidget *tooltipbox;
GtkWidget *summary_window;
- GArray *labels;
-
gint panel_size;
gint size;
GtkOrientation orientation;
@@ -55,6 +53,11 @@ typedef struct {
time_t last_data_update;
time_t last_conditions_update;
+ GtkWidget *scrollbox;
+ gboolean show_scrollbox;
+ guint scrollbox_lines;
+ GArray *labels;
+
icon_theme *icon_theme;
gchar *location_name;
More information about the Xfce4-commits
mailing list