[Xfce4-commits] <xfce4-weather-plugin:master> Update summary window when changing relevant settings.

Harald Judt noreply at xfce.org
Thu Nov 29 11:06:01 CET 2012


Updating branch refs/heads/master
         to da378e359acd7f31fb0c9511f328f2e678dcc1d0 (commit)
       from 6c027335468aca1c7c245585e41d8d5d406350ce (commit)

commit da378e359acd7f31fb0c9511f328f2e678dcc1d0
Author: Harald Judt <h.judt at gmx.at>
Date:   Thu Nov 29 10:48:19 2012 +0100

    Update summary window when changing relevant settings.
    
    Recreate the summary window when the users changes settings that affect it,
    with the exception being the settings on the location page. If the forecast
    layout is not changed, the position of the window will be restored too.
    
    The configuration dialog will always be kept in the foreground.

 panel-plugin/weather-config.c |   36 ++++++++++++++++++++++++++++++++++++
 panel-plugin/weather.c        |    2 +-
 panel-plugin/weather.h        |    3 +++
 3 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index d2c5652..290c25e 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -109,6 +109,33 @@ spin_alt_value_changed(const GtkWidget *spin,
                        gpointer user_data);
 
 
+static void
+update_summary_window(xfceweather_dialog *dialog,
+                      gboolean restore_position)
+{
+    if (dialog->wd->summary_window) {
+        guint x, y;
+
+        /* remember position */
+        if (restore_position)
+            gtk_window_get_position(GTK_WINDOW(dialog->wd->summary_window),
+                                    &x, &y);
+
+        /* call toggle function two times to close and open dialog */
+        forecast_click(dialog->wd->summary_window, dialog->wd);
+        forecast_click(dialog->wd->summary_window, dialog->wd);
+
+        /* ask wm to restore position of new window */
+        if (restore_position)
+            gtk_window_move(GTK_WINDOW(dialog->wd->summary_window), x, y);
+
+        /* bring config dialog to the front, it might have been hidden
+         * beneath the summary window */
+        gtk_window_present(GTK_WINDOW(dialog->dialog));
+    }
+}
+
+
 static gboolean
 schedule_data_update(gpointer user_data)
 {
@@ -533,6 +560,7 @@ combo_unit_temperature_changed(GtkWidget *combo,
     dialog->wd->units->temperature =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
     update_scrollbox(dialog->wd);
+    update_summary_window(dialog, TRUE);
 }
 
 
@@ -544,6 +572,7 @@ combo_unit_pressure_changed(GtkWidget *combo,
     dialog->wd->units->pressure =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
     update_scrollbox(dialog->wd);
+    update_summary_window(dialog, TRUE);
 }
 
 
@@ -555,6 +584,7 @@ combo_unit_windspeed_changed(GtkWidget *combo,
     dialog->wd->units->windspeed =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
     update_scrollbox(dialog->wd);
+    update_summary_window(dialog, TRUE);
 }
 
 
@@ -566,6 +596,7 @@ combo_unit_precipitations_changed(GtkWidget *combo,
     dialog->wd->units->precipitations =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
     update_scrollbox(dialog->wd);
+    update_summary_window(dialog, TRUE);
 }
 
 
@@ -578,6 +609,7 @@ combo_unit_altitude_changed(GtkWidget *combo,
     dialog->wd->units->altitude =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
     setup_altitude(dialog);
+    update_summary_window(dialog, TRUE);
 }
 
 
@@ -674,6 +706,7 @@ combo_icon_theme_changed(GtkWidget *combo,
     icon_theme_free(dialog->wd->icon_theme);
     dialog->wd->icon_theme = icon_theme_copy(theme);
     update_icon(dialog->wd);
+    update_summary_window(dialog, TRUE);
 }
 
 
@@ -693,6 +726,7 @@ combo_forecast_layout_changed(GtkWidget *combo,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->wd->forecast_layout =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
+    update_summary_window(dialog, FALSE);
 }
 
 
@@ -703,6 +737,7 @@ spin_forecast_days_value_changed(const GtkWidget *spin,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->wd->forecast_days =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
+    update_summary_window(dialog, FALSE);
 }
 
 
@@ -714,6 +749,7 @@ check_round_values_toggled(GtkWidget *button,
     dialog->wd->round =
         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
     update_scrollbox(dialog->wd);
+    update_summary_window(dialog, TRUE);
 }
 
 
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 5c317a0..71faf8f 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -692,7 +692,7 @@ close_summary(GtkWidget *widget,
 }
 
 
-static void
+void
 forecast_click(GtkWidget *widget,
                gpointer user_data)
 {
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index c74625f..87ce68e 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -108,6 +108,9 @@ void weather_http_queue_request(SoupSession *session,
 
 void scrollbox_set_visible(xfceweather_data *data);
 
+void forecast_click(GtkWidget *widget,
+                    gpointer user_data);
+
 void update_icon(xfceweather_data *data);
 
 void update_scrollbox(xfceweather_data *data);


More information about the Xfce4-commits mailing list