From 286f561088010132357e855e945c49af8995fece Mon Sep 17 00:00:00 2001 From: Mike Massonnet Date: Sat, 22 May 2010 22:45:38 +0200 Subject: [PATCH] =?UTF-8?q?Implement=20option=20=E2=80=9CRefresh=20rate?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index cb1d8b9..6d891c3 100644 --- a/src/main.c +++ b/src/main.c @@ -15,9 +15,11 @@ #include #include +#include "settings.h" #include "process-window.h" #include "task-manager.h" +static XtmSettings *settings; static GtkWidget *window; static XtmTaskManager *task_manager; static gboolean timeout = 0; @@ -34,11 +36,27 @@ init_timeout (void) xtm_task_manager_update_model (task_manager); if (timeout == 0) - timeout = g_timeout_add (1000, (GSourceFunc)init_timeout, NULL); + { + guint refresh_rate; + g_object_get (settings, "refresh-rate", &refresh_rate, NULL); + timeout = g_timeout_add (refresh_rate, (GSourceFunc)init_timeout, NULL); + } return TRUE; } +static void +refresh_rate_changed (XtmSettings *settings) +{ + if (!g_source_remove (timeout)) + { + g_critical ("Unable to remove source"); + return; + } + timeout = 0; + init_timeout (); +} + int main (int argc, char *argv[]) { #ifdef ENABLE_NLS @@ -49,6 +67,8 @@ int main (int argc, char *argv[]) gtk_init (&argc, &argv); + settings = xtm_settings_get_default (); + window = xtm_process_window_new (); gtk_widget_show (window); @@ -56,6 +76,7 @@ int main (int argc, char *argv[]) g_message ("Running as %s on %s", xtm_task_manager_get_username (task_manager), xtm_task_manager_get_hostname (task_manager)); init_timeout (); + g_signal_connect (settings, "notify::refresh-rate", G_CALLBACK (refresh_rate_changed), NULL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);