[gtk+] window: Only update the inspector once



commit 5037d134c56ab827a18b965442f5fcac95c9ee8a
Author: Benjamin Otte <otte redhat com>
Date:   Tue Aug 25 19:46:09 2015 +0200

    window: Only update the inspector once
    
    Instead of queueing a new idle handler every time we call
    gtk_window_update_debugging(), only queue one if none is queued that.
    
    Saves a lot of work, in particular when templates create context menus
    for every row in a large listbox as in the gtk-demo listbox example.

 gtk/gtkwindow.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 0367c90..126f8f9 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -12051,21 +12051,24 @@ warn_response (GtkDialog *dialog,
     }
 }
 
+static guint gtk_window_update_debugging_id;
+
 static gboolean
 update_debugging (gpointer data)
 {
   gtk_inspector_window_rescan (inspector_window);
+  gtk_window_update_debugging_id = 0;
   return G_SOURCE_REMOVE;
 }
 
 static void
 gtk_window_update_debugging (void)
 {
-  if (inspector_window)
+  if (inspector_window &&
+      gtk_window_update_debugging_id == 0)
     {
-      guint id;
-      id = gdk_threads_add_idle (update_debugging, NULL);
-      g_source_set_name_by_id (id, "[gtk+] gtk_window_update_debugging");
+      gtk_window_update_debugging_id = gdk_threads_add_idle (update_debugging, NULL);
+      g_source_set_name_by_id (gtk_window_update_debugging_id, "[gtk+] gtk_window_update_debugging");
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]