[Xfce4-commits] <xfce4-cpufreq-plugin:master> Use g_timeout_add_seconds for less wake-ups
Florian Rivoal
noreply at xfce.org
Thu Dec 30 19:34:01 CET 2010
Updating branch refs/heads/master
to 74c9bfcb925fb2095efff6f45764f5e209c126ed (commit)
from f5b204d2590618955f0ead8f9ce672fdeae3ee3b (commit)
commit 74c9bfcb925fb2095efff6f45764f5e209c126ed
Author: Florian Rivoal <frivoal at xfce.org>
Date: Fri Dec 31 03:28:11 2010 +0900
Use g_timeout_add_seconds for less wake-ups
Fixes bug #5180
panel-plugin/xfce4-cpufreq-configure.c | 9 ++-------
panel-plugin/xfce4-cpufreq-configure.h | 4 ++++
panel-plugin/xfce4-cpufreq-plugin.c | 8 +++++---
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/panel-plugin/xfce4-cpufreq-configure.c b/panel-plugin/xfce4-cpufreq-configure.c
index 1f04058..4774ee1 100644
--- a/panel-plugin/xfce4-cpufreq-configure.c
+++ b/panel-plugin/xfce4-cpufreq-configure.c
@@ -17,9 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#define BORDER 1
-#define TIMEOUT_MIN 0.5
-#define TIMEOUT_MAX 3
-#define TIMEOUT_STEP 0.5
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -72,9 +69,7 @@ combo_changed (GtkWidget *combo, CpuFreqPluginConfigure *configure)
static void
spinner_changed (GtkWidget *spinner, CpuFreqPluginConfigure *configure)
{
- gdouble timeout = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinner));
- timeout *= 100;
- cpuFreq->options->timeout = timeout;
+ cpuFreq->options->timeout =gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinner));
cpufreq_restart_timeout ();
}
@@ -145,7 +140,7 @@ cpufreq_configure (XfcePanelPlugin *plugin)
spinner = configure->spinner_timeout =
gtk_spin_button_new_with_range (TIMEOUT_MIN, TIMEOUT_MAX, TIMEOUT_STEP);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinner), (gdouble)cpuFreq->options->timeout / 100);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinner), (gdouble)cpuFreq->options->timeout);
gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (spinner), "value-changed", G_CALLBACK (spinner_changed), configure);
diff --git a/panel-plugin/xfce4-cpufreq-configure.h b/panel-plugin/xfce4-cpufreq-configure.h
index d30060d..f4f6f63 100644
--- a/panel-plugin/xfce4-cpufreq-configure.h
+++ b/panel-plugin/xfce4-cpufreq-configure.h
@@ -32,6 +32,10 @@ G_BEGIN_DECLS
void
cpufreq_configure (XfcePanelPlugin *plugin);
+#define TIMEOUT_MIN 1
+#define TIMEOUT_MAX 10
+#define TIMEOUT_STEP 1
+
G_END_DECLS
#endif /* XFCE4_CPUFREQ_CONFIGURE_H */
diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c
index d6ba02a..5aae763 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.c
+++ b/panel-plugin/xfce4-cpufreq-plugin.c
@@ -114,7 +114,7 @@ void
cpufreq_restart_timeout (void)
{
g_source_remove (cpuFreq->timeoutHandle);
- cpuFreq->timeoutHandle = g_timeout_add (
+ cpuFreq->timeoutHandle = g_timeout_add_seconds (
cpuFreq->options->timeout,
(GSourceFunc)cpufreq_update_cpus,
NULL);
@@ -196,7 +196,9 @@ cpufreq_read_config (void)
rc = xfce_rc_simple_open (file, FALSE);
g_free (file);
- cpuFreq->options->timeout = xfce_rc_read_int_entry (rc, "timeout", 100);
+ cpuFreq->options->timeout = xfce_rc_read_int_entry (rc, "timeout", 1);
+ if (cpuFreq->options->timeout > TIMEOUT_MAX || cpuFreq->options->timeout < TIMEOUT_MIN)
+ cpuFreq->options->timeout = TIMEOUT_MIN;
cpuFreq->options->show_cpu = xfce_rc_read_int_entry (rc, "show_cpu", 0);
cpuFreq->options->show_frame = xfce_rc_read_bool_entry (rc, "show_frame", TRUE);
cpuFreq->options->show_icon = xfce_rc_read_bool_entry (rc, "show_icon", TRUE);
@@ -291,7 +293,7 @@ cpufreq_construct (XfcePanelPlugin *plugin)
cpufreq_widgets ();
- cpuFreq->timeoutHandle = g_timeout_add (
+ cpuFreq->timeoutHandle = g_timeout_add_seconds (
cpuFreq->options->timeout,
(GSourceFunc) cpufreq_update_cpus,
NULL);
More information about the Xfce4-commits
mailing list