[Xfce4-commits] <xfce4-weather-plugin:master> Synchronise the toggle button state with the summary window.
Harald Judt
noreply at xfce.org
Thu Jan 24 21:12:02 CET 2013
Updating branch refs/heads/master
to 1bc73ddae784df6dee36f3bb0c716bbba7fb9f46 (commit)
from 14acac625e28195f6f1eaa04ecfa5cd8c8697596 (commit)
commit 1bc73ddae784df6dee36f3bb0c716bbba7fb9f46
Author: Harald Judt <h.judt at gmx.at>
Date: Thu Jan 24 20:54:30 2013 +0100
Synchronise the toggle button state with the summary window.
This needs a bit of trickery, because the toggle signal is emitted whenever
we want to change its state. So we will handle the toggle signal itself
in a callback function which sets the proper state while blocking another
toggle signal. The actual clicks are still handled by cb_click.
panel-plugin/weather.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 3b6a7c8..53f18f2 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -1289,6 +1289,24 @@ update_weatherdata_with_reset(plugin_data *data, gboolean clear)
}
+/* This is only a dummy handler, the clicks will be processed by
+ cb_click. This is needed to synchronise the toggled state with
+ the existence of the summary window. */
+static gboolean
+cb_toggled(GtkToggleButton *button,
+ gpointer user_data)
+{
+ plugin_data *data = (plugin_data *) user_data;
+ g_signal_handlers_block_by_func(data->button, cb_toggled, data);
+ if (data->summary_window)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->button), TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->button), FALSE);
+ g_signal_handlers_unblock_by_func(data->button, cb_toggled, data);
+ return FALSE;
+}
+
+
static void
close_summary(GtkWidget *widget,
gpointer *user_data)
@@ -1299,6 +1317,9 @@ close_summary(GtkWidget *widget,
summary_details_free(data->summary_details);
data->summary_details = NULL;
data->summary_window = NULL;
+
+ /* sync toggle button state */
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->button), FALSE);
}
@@ -1311,6 +1332,9 @@ forecast_click(GtkWidget *widget,
if (data->summary_window != NULL)
gtk_widget_destroy(data->summary_window);
else {
+ /* sync toggle button state */
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->button), TRUE);
+
data->summary_window = create_summary_window(data);
g_signal_connect(G_OBJECT(data->summary_window), "destroy",
G_CALLBACK(close_summary), data);
@@ -1330,7 +1354,6 @@ cb_click(GtkWidget *widget,
forecast_click(widget, user_data);
else if (event->button == 2)
update_weatherdata_with_reset(data, FALSE);
-
return FALSE;
}
@@ -1669,6 +1692,8 @@ xfceweather_create_control(XfcePanelPlugin *plugin)
G_CALLBACK(cb_click), data);
g_signal_connect(G_OBJECT(data->button), "scroll-event",
G_CALLBACK(cb_scroll), data);
+ g_signal_connect(G_OBJECT(data->button), "toggled",
+ G_CALLBACK(cb_toggled), data);
gtk_widget_add_events(data->scrollbox, GDK_BUTTON_PRESS_MASK);
/* add refresh button to right click menu, for people who missed
More information about the Xfce4-commits
mailing list