[Xfce4-commits] <xfce4-weather-plugin:master> Remove code duplication for showing/hiding scrollbox.

Harald Judt noreply at xfce.org
Tue Nov 27 16:46:26 CET 2012


Updating branch refs/heads/master
         to 402646ca5d8ddef4ffc5c777a9a12d3618546025 (commit)
       from 2b4a3f01cd65a00868af9b468943d807039a6c92 (commit)

commit 402646ca5d8ddef4ffc5c777a9a12d3618546025
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun Nov 25 15:36:47 2012 +0100

    Remove code duplication for showing/hiding scrollbox.
    
    scrollbox_set_visible is a better name than toggle_scrollbox,
    considering the way the function works.

 panel-plugin/weather-config.c |    2 +-
 panel-plugin/weather.c        |   19 ++++---------------
 panel-plugin/weather.h        |    2 +-
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 42e203f..4a95722 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -776,7 +776,7 @@ check_scrollbox_show_toggled(GtkWidget *button,
     xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
     dialog->wd->show_scrollbox =
         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
-    toggle_scrollbox(dialog->wd);
+    scrollbox_set_visible(dialog->wd);
 }
 
 
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 7fb9a88..a4b8f03 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -222,9 +222,9 @@ update_icon(xfceweather_data *data)
 
 
 void
-toggle_scrollbox(xfceweather_data *data)
+scrollbox_set_visible(xfceweather_data *data)
 {
-    if (data->show_scrollbox)
+    if (data->show_scrollbox && data->labels->len > 0)
         gtk_widget_show_all(GTK_WIDGET(data->vbox_center_scrollbox));
     else
         gtk_widget_hide_all(GTK_WIDGET(data->vbox_center_scrollbox));
@@ -264,7 +264,7 @@ update_scrollbox(xfceweather_data *data)
     }
 
     /* show or hide scrollbox */
-    toggle_scrollbox(data);
+    scrollbox_set_visible(data);
 
     weather_debug("Updated scrollbox.");
 }
@@ -483,16 +483,6 @@ labels_clear(GArray *array)
 
 
 static void
-xfceweather_set_visibility(xfceweather_data *data)
-{
-    if (data->labels->len > 0)
-        gtk_widget_show(data->scrollbox);
-    else
-        gtk_widget_hide(data->scrollbox);
-}
-
-
-static void
 xfceweather_read_config(XfcePanelPlugin *plugin,
                         xfceweather_data *data)
 {
@@ -785,7 +775,6 @@ xfceweather_dialog_response(GtkWidget *dlg,
         xfceweather_write_config(data->plugin, data);
 #endif
 
-        xfceweather_set_visibility(data);
     }
 }
 
@@ -1272,7 +1261,7 @@ weather_construct(XfcePanelPlugin *plugin)
     xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
     data = xfceweather_create_control(plugin);
     xfceweather_read_config(plugin, data);
-    xfceweather_set_visibility(data);
+    scrollbox_set_visible(data);
 
 #if LIBXFCE4PANEL_CHECK_VERSION(4,9,0)
     xfceweather_set_mode(plugin, xfce_panel_plugin_get_mode(plugin), data);
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index b3a8da4..05a6de2 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -89,7 +89,7 @@ void weather_http_queue_request(SoupSession *session,
                                 SoupSessionCallback callback_func,
                                 gpointer user_data);
 
-void toggle_scrollbox(xfceweather_data *data);
+void scrollbox_set_visible(xfceweather_data *data);
 
 void update_scrollbox(xfceweather_data *data);
 


More information about the Xfce4-commits mailing list