[Xfce4-commits] <xfce4-weather-plugin:master> Scrollbox: Immediately update labels after config change.

Harald Judt noreply at xfce.org
Sat Jan 5 12:04:03 CET 2013


Updating branch refs/heads/master
         to 452f5166f5fb2817c38a9ee637d91992c21b35e4 (commit)
       from 23f5db0ca7aed912c096b971ac1cd968ed101d57 (commit)

commit 452f5166f5fb2817c38a9ee637d91992c21b35e4
Author: Harald Judt <h.judt at gmx.at>
Date:   Wed Jan 2 18:17:06 2013 +0100

    Scrollbox: Immediately update labels after config change.

 panel-plugin/weather-config.c    |   14 +++++++-------
 panel-plugin/weather-scrollbox.c |    2 +-
 panel-plugin/weather-scrollbox.h |    2 ++
 panel-plugin/weather.c           |   20 +++++++++++++-------
 panel-plugin/weather.h           |    3 ++-
 5 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 1eee0c5..5f6a420 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -613,7 +613,7 @@ combo_unit_temperature_changed(GtkWidget *combo,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->pd->units->temperature =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
-    update_scrollbox(dialog->pd);
+    update_scrollbox(dialog->pd, TRUE);
     update_summary_window(dialog, TRUE);
 }
 
@@ -625,7 +625,7 @@ combo_unit_pressure_changed(GtkWidget *combo,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->pd->units->pressure =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
-    update_scrollbox(dialog->pd);
+    update_scrollbox(dialog->pd, TRUE);
     update_summary_window(dialog, TRUE);
 }
 
@@ -637,7 +637,7 @@ combo_unit_windspeed_changed(GtkWidget *combo,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->pd->units->windspeed =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
-    update_scrollbox(dialog->pd);
+    update_scrollbox(dialog->pd, TRUE);
     update_summary_window(dialog, TRUE);
 }
 
@@ -649,7 +649,7 @@ combo_unit_precipitations_changed(GtkWidget *combo,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->pd->units->precipitations =
         gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
-    update_scrollbox(dialog->pd);
+    update_scrollbox(dialog->pd, TRUE);
     update_summary_window(dialog, TRUE);
 }
 
@@ -835,7 +835,7 @@ check_round_values_toggled(GtkWidget *button,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->pd->round =
         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
-    update_scrollbox(dialog->pd);
+    update_scrollbox(dialog->pd, TRUE);
     update_summary_window(dialog, TRUE);
 }
 
@@ -941,7 +941,7 @@ spin_scrollbox_lines_value_changed(const GtkWidget *spin,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->pd->scrollbox_lines =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
-    update_scrollbox(dialog->pd);
+    update_scrollbox(dialog->pd, FALSE);
 }
 
 
@@ -1074,7 +1074,7 @@ update_scrollbox_labels(xfceweather_dialog *dialog)
             gtk_tree_model_iter_next(GTK_TREE_MODEL(dialog->model_datatypes),
                                      &iter);
     }
-    update_scrollbox(dialog->pd);
+    update_scrollbox(dialog->pd, TRUE);
 }
 
 
diff --git a/panel-plugin/weather-scrollbox.c b/panel-plugin/weather-scrollbox.c
index 63c0ef6..3cb39de 100644
--- a/panel-plugin/weather-scrollbox.c
+++ b/panel-plugin/weather-scrollbox.c
@@ -242,7 +242,7 @@ gtk_scrollbox_add_label(GtkScrollbox *self,
  * Sets new labels active if there are any, or advances the current
  * label.
  */
-static void
+void
 gtk_scrollbox_swap_labels(GtkScrollbox *self)
 {
     gint pos;
diff --git a/panel-plugin/weather-scrollbox.h b/panel-plugin/weather-scrollbox.h
index 937e07f..7a04411 100644
--- a/panel-plugin/weather-scrollbox.h
+++ b/panel-plugin/weather-scrollbox.h
@@ -80,6 +80,8 @@ GtkWidget *gtk_scrollbox_new(void);
 
 void gtk_scrollbox_clear_new(GtkScrollbox *self);
 
+void gtk_scrollbox_swap_labels(GtkScrollbox *self);
+
 void gtk_scrollbox_reset(GtkScrollbox *self);
 
 void gtk_scrollbox_set_animate(GtkScrollbox *self,
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 07edbd9..db3a0a5 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -277,7 +277,8 @@ scrollbox_set_visible(plugin_data *data)
 
 
 void
-update_scrollbox(plugin_data *data)
+update_scrollbox(plugin_data *data,
+                 gboolean immediately)
 {
     GString *out;
     gchar *label = NULL;
@@ -313,6 +314,11 @@ update_scrollbox(plugin_data *data)
     }
     gtk_scrollbox_set_animate(GTK_SCROLLBOX(data->scrollbox),
                               data->scrollbox_animate);
+    /* update labels immediately (mainly used on config change) */
+    if (immediately) {
+        gtk_scrollbox_prev_label(GTK_SCROLLBOX(data->scrollbox));
+        gtk_scrollbox_swap_labels(GTK_SCROLLBOX(data->scrollbox));
+    }
     scrollbox_set_visible(data);
     weather_debug("Updated scrollbox.");
 }
@@ -325,7 +331,7 @@ update_current_conditions(plugin_data *data)
 
     if (G_UNLIKELY(data->weatherdata == NULL)) {
         update_icon(data);
-        update_scrollbox(data);
+        update_scrollbox(data, FALSE);
         return;
     }
 
@@ -354,7 +360,7 @@ update_current_conditions(plugin_data *data)
 
     /* update widgets */
     update_icon(data);
-    update_scrollbox(data);
+    update_scrollbox(data, FALSE);
     weather_debug("Updated current conditions.");
 }
 
@@ -510,7 +516,7 @@ update_handler(plugin_data *data)
 
     if (G_UNLIKELY(data->lat == NULL || data->lon == NULL)) {
         update_icon(data);
-        update_scrollbox(data);
+        update_scrollbox(data, FALSE);
         return FALSE;
     }
 
@@ -1593,7 +1599,7 @@ xfceweather_set_size(XfcePanelPlugin *panel,
     data->size = size;
 
     update_icon(data);
-    update_scrollbox(data);
+    update_scrollbox(data, FALSE);
 
     weather_dump(weather_dump_plugindata, data);
 
@@ -1634,7 +1640,7 @@ xfceweather_set_mode(XfcePanelPlugin *panel,
                                   data->orientation);
 
     update_icon(data);
-    update_scrollbox(data);
+    update_scrollbox(data, FALSE);
 
     weather_dump(weather_dump_plugindata, data);
 
@@ -1671,7 +1677,7 @@ xfceweather_set_orientation(XfcePanelPlugin *panel,
                                   data->panel_orientation);
 
     update_icon(data);
-    update_scrollbox(data);
+    update_scrollbox(data, FALSE);
 
     weather_dump(weather_dump_plugindata, data);
 
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index 5d2425e..e3461c3 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -128,7 +128,8 @@ gchar *get_cache_directory(void);
 
 void update_icon(plugin_data *data);
 
-void update_scrollbox(plugin_data *data);
+void update_scrollbox(plugin_data *data,
+                      gboolean immediately);
 
 void update_weatherdata_with_reset(plugin_data *data,
                                    gboolean clear);


More information about the Xfce4-commits mailing list