[Xfce4-commits] <xfce4-wavelan-plugin:master> Wake up less often to save power

Florian Rivoal noreply at xfce.org
Fri Nov 19 15:22:02 CET 2010


Updating branch refs/heads/master
         to bb704d0fe9a1df145df578944dc03439ba19cbac (commit)
       from 24812523c0a03512fcd009132a859c38fd8cddfd (commit)

commit bb704d0fe9a1df145df578944dc03439ba19cbac
Author: Florian Rivoal <frivoal at xfce.org>
Date:   Mon Nov 15 10:49:38 2010 +0900

    Wake up less often to save power
    
    Use g_timeout_add_seconds instead of g_timeout_add for less frequent
    wake ups, which should help (even if only a little) with battery life.
    
    based on a patch submitted in bug #5181.

 panel-plugin/wavelan.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/panel-plugin/wavelan.c b/panel-plugin/wavelan.c
index f3ca7ad..3716c0c 100644
--- a/panel-plugin/wavelan.c
+++ b/panel-plugin/wavelan.c
@@ -177,6 +177,16 @@ wavelan_timer(gpointer data)
   return(TRUE);
 }
 
+inline guint
+timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
+{
+#if GLIB_CHECK_VERSION( 2,14,0 )
+  return g_timeout_add_seconds(interval, function, data);
+#else
+  return g_timeout_add(interval*1000, function, data);
+#endif
+}
+
 static void
 wavelan_reset(t_wavelan *wavelan)
 {
@@ -197,7 +207,7 @@ wavelan_reset(t_wavelan *wavelan)
     if ((wavelan->device = wi_open(wavelan->interface)) != NULL) {
       /* register the update timer */
       TRACE ("Opened device");
-      wavelan->timer_id = g_timeout_add(250, wavelan_timer, wavelan);
+      wavelan->timer_id = timeout_add_seconds(1, wavelan_timer, wavelan);
     }
   }
 }



More information about the Xfce4-commits mailing list