From 2937a09ead08858a6bb4176ecafb4c1bf7dff735 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sat, 6 Dec 2008 21:29:39 +0000 Subject: [PATCH] Use g_timeout_add_seconds() for power efficiency This attempts to align second-granularity wakeups across the system, reducing CPU wakeups a little. I considered all timeouts of duration 1 second or greater, and moved the non-timing-critical ones to g_timeout_add_seconds(). (Actually, I didn't find any that I felt were timing-critical) --- src/sugar/acme-volume-alsa.c | 2 +- src/sugar/activity/activity.py | 4 ++-- src/sugar/eggdesktopfile.c | 4 ++-- src/sugar/graphics/alert.py | 2 +- src/sugar/gsm-client-xsmp.c | 2 +- src/sugar/gsm-session.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sugar/acme-volume-alsa.c b/src/sugar/acme-volume-alsa.c index c1ea5ccf..42bbf4e1 100644 --- a/src/sugar/acme-volume-alsa.c +++ b/src/sugar/acme-volume-alsa.c @@ -292,7 +292,7 @@ bail: static void acme_volume_alsa_close (AcmeVolumeAlsa *self) { - self->_priv->timer_id = g_timeout_add (4000, + self->_priv->timer_id = g_timeout_add_seconds (4, (GSourceFunc) acme_volume_alsa_close_real, self); } diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index acefcf44..66669c8f 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -184,8 +184,8 @@ class ActivityToolbar(gtk.Toolbar): def __title_changed_cb(self, entry): if not self._update_title_sid: - self._update_title_sid = gobject.timeout_add( - 1000, self.__update_title_cb) + self._update_title_sid = gobject.timeout_add_seconds( + 1, self.__update_title_cb) def __update_title_cb(self): title = self.title.get_text() diff --git a/src/sugar/eggdesktopfile.c b/src/sugar/eggdesktopfile.c index ad783451..eb28b9d6 100644 --- a/src/sugar/eggdesktopfile.c +++ b/src/sugar/eggdesktopfile.c @@ -955,7 +955,7 @@ end_startup_notification (GdkDisplay *display, NULL); } -#define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH (30 /* seconds */ * 1000) +#define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH 30 /* seconds */ typedef struct { GdkDisplay *display; @@ -985,7 +985,7 @@ set_startup_notification_timeout (GdkDisplay *display, sn_data->display = g_object_ref (display); sn_data->startup_id = g_strdup (startup_id); - g_timeout_add (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH, + g_timeout_add_seconds (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH, startup_notification_timeout, sn_data); } #endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */ diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py index 6cfa0fac..2c3c4caf 100644 --- a/src/sugar/graphics/alert.py +++ b/src/sugar/graphics/alert.py @@ -376,7 +376,7 @@ class TimeoutAlert(Alert): canvas.show() self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas) - gobject.timeout_add(1000, self.__timeout) + gobject.timeout_add_seconds(1, self.__timeout) def __timeout(self): self._timeout -= 1 diff --git a/src/sugar/gsm-client-xsmp.c b/src/sugar/gsm-client-xsmp.c index dcacc6f2..04c7de47 100644 --- a/src/sugar/gsm-client-xsmp.c +++ b/src/sugar/gsm-client-xsmp.c @@ -110,7 +110,7 @@ gsm_client_xsmp_new (IceConn ice_conn) client_iochannel_watch, xsmp); g_io_channel_unref (channel); - xsmp->protocol_timeout = g_timeout_add (5000, client_protocol_timeout, xsmp); + xsmp->protocol_timeout = g_timeout_add_seconds (5, client_protocol_timeout, xsmp); set_description (xsmp); g_debug ("New client '%s'", xsmp->description); diff --git a/src/sugar/gsm-session.c b/src/sugar/gsm-session.c index b1f4f0e4..0fe2fb53 100644 --- a/src/sugar/gsm-session.c +++ b/src/sugar/gsm-session.c @@ -203,7 +203,7 @@ start_phase (GsmSession *session) { if (session->phase < GSM_SESSION_PHASE_APPLICATION) { - session->timeout = g_timeout_add (GSM_SESSION_PHASE_TIMEOUT * 1000, + session->timeout = g_timeout_add_seconds (GSM_SESSION_PHASE_TIMEOUT, phase_timeout, session); } }