Updating branch refs/heads/master
         to 286f561088010132357e855e945c49af8995fece (commit)
       from 91d509ccdb01ea0dc95c8bc5240fb8a09c075895 (commit)

commit 286f561088010132357e855e945c49af8995fece
Author: Mike Massonnet <[email protected]>
Date:   Sat May 22 22:45:38 2010 +0200

    Implement option “Refresh rate”

 src/main.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

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 <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#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);
 
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to