[Xfce4-commits] <xfce4-weather-plugin:master> Scrollbox: Use g_timeout_add_seconds where applicable.

Harald Judt noreply at xfce.org
Sat Dec 15 21:22:12 CET 2012


Updating branch refs/heads/master
         to fdabe8fa3595ec9bd3ef5a97dcba74c355f6ee00 (commit)
       from e7cd852e19c59c57f39b01d6b4a5de17b2e8a2e7 (commit)

commit fdabe8fa3595ec9bd3ef5a97dcba74c355f6ee00
Author: Harald Judt <h.judt at gmx.at>
Date:   Sat Dec 15 20:42:14 2012 +0100

    Scrollbox: Use g_timeout_add_seconds where applicable.
    
    From the GLib Reference Manual:
    "If you want to have a timer in the "seconds" range and do not care about the
     exact time of the first call of the timer, use the g_timeout_add_seconds()
     function; this function allows for more optimizations and more efficient
     system power usage."
    
    This leaves g_timeout_add only for the sleep periods that control the
    label fade in / out speed.

 panel-plugin/weather-scrollbox.c |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/panel-plugin/weather-scrollbox.c b/panel-plugin/weather-scrollbox.c
index 72427ce..ddd78b2 100644
--- a/panel-plugin/weather-scrollbox.c
+++ b/panel-plugin/weather-scrollbox.c
@@ -28,8 +28,9 @@
 
 #include "weather-scrollbox.h"
 
-#define LABEL_REFRESH (3000)
-#define LABEL_REFRESH_NO_ANIMATION (5000)
+#define LABEL_REFRESH (3)
+#define LABEL_REFRESH_NO_ANIMATION (6)
+#define LABEL_REFRESH_NO_ANIM_INIT (1)
 #define LABEL_SPEED (25)
 
 
@@ -295,8 +296,8 @@ gtk_scrollbox_fade_none(gpointer user_data)
     gtk_scrollbox_swap_labels(self);
     gtk_scrollbox_next_label(self);
 
-    self->timeout_id = g_timeout_add(LABEL_REFRESH_NO_ANIMATION,
-                                     gtk_scrollbox_fade_none, self);
+    self->timeout_id = g_timeout_add_seconds(LABEL_REFRESH_NO_ANIMATION,
+                                             gtk_scrollbox_fade_none, self);
     return FALSE;
 }
 
@@ -332,12 +333,14 @@ gtk_scrollbox_fade_in(gpointer user_data)
     if (self->visible)
         if (self->animate) {
             self->fade = FADE_OUT;
-            self->timeout_id = g_timeout_add(LABEL_REFRESH,
-                                             gtk_scrollbox_sleep, self);
+            self->timeout_id =
+                g_timeout_add_seconds(LABEL_REFRESH,
+                                      gtk_scrollbox_sleep, self);
         } else {
             self->fade = FADE_NONE;
-            self->timeout_id = g_timeout_add(LABEL_REFRESH_NO_ANIMATION,
-                                             gtk_scrollbox_fade_none, self);
+            self->timeout_id =
+                g_timeout_add_seconds(LABEL_REFRESH_NO_ANIMATION,
+                                      gtk_scrollbox_fade_none, self);
         }
     return FALSE;
 }
@@ -440,8 +443,9 @@ gtk_scrollbox_reset(GtkScrollbox *self)
         gtk_scrollbox_start_fade(self);
     else {
         self->fade = FADE_NONE;
-        self->timeout_id = g_timeout_add(LABEL_REFRESH_NO_ANIMATION,
-                                         gtk_scrollbox_fade_none, self);
+        self->timeout_id =
+            g_timeout_add_seconds(LABEL_REFRESH_NO_ANIMATION,
+                                  gtk_scrollbox_fade_none, self);
     }
     gtk_widget_queue_resize(GTK_WIDGET(self));
 }
@@ -471,9 +475,10 @@ gtk_scrollbox_set_visible(GtkScrollbox *self,
                 gtk_scrollbox_start_fade(self);
             else {
                 self->fade = FADE_NONE;
-                self->timeout_id = g_timeout_add(1000,
-                                                 gtk_scrollbox_fade_none,
-                                                 self);
+                self->timeout_id =
+                    g_timeout_add_seconds(LABEL_REFRESH_NO_ANIM_INIT,
+                                          gtk_scrollbox_fade_none,
+                                          self);
             }
     } else
         if (self->timeout_id != 0) {


More information about the Xfce4-commits mailing list