Author: arj
Date: Mon Jan  7 10:37:42 2008
New Revision: 21
URL: http://svn.gnome.org/viewvc/nemo?rev=21&view=rev

Log:
Make resize work a little better by not redrawing so often



Modified:
   trunk/NEWS
   trunk/common/Common.cs
   trunk/gtk/FixedResizeWidget.cs
   trunk/metadata/MetadataStore.cs

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS  (original)
+++ trunk/NEWS  Mon Jan  7 10:37:42 2008
@@ -5,6 +5,7 @@
 - Fix indexing so it doesn't kill the machine
 - Fix bug that caused a crash in metadata store
 - Optimize metadata store to be faster at checking for valid files
+- Make resize work a little better by not redrawing so often
 
 0.1.2 alpha
 -----------

Modified: trunk/common/Common.cs
==============================================================================
--- trunk/common/Common.cs      (original)
+++ trunk/common/Common.cs      Mon Jan  7 10:37:42 2008
@@ -32,7 +32,7 @@
 
                private static Timer update_timer;
 
-               public static void RunOnlyOnce(VoidFunction func, int timeout 
/* ms */)
+               public static void RunOnlyOnceFIFO(VoidFunction func, int 
timeout /* ms */)
                {
             if (update_timer != null)
                 return;
@@ -41,6 +41,17 @@
                                         timeout /* msecs */, Timeout.Infinite);
         }
 
+               public static void RunOnlyOnceLIFO(VoidFunction func, int 
timeout /* ms */)
+               {
+            if (update_timer != null) {
+                   update_timer.Dispose();
+                   update_timer = null;
+                }
+            
+            update_timer = new Timer(delegate(Object s) { 
RunOnlyOnceTimedOut(func); }, null,
+                                        timeout /* msecs */, Timeout.Infinite);
+        }
+
                public static void RunOnlyOnceTimedOut(VoidFunction func)
                {
             func();
@@ -48,6 +59,21 @@
             update_timer = null;
                }
 
+               static Dictionary<string, int> main_last_id = new 
Dictionary<string,int>();
+
+               public static void RunOnlyOnceInMainLIFO(string name, 
VoidFunction func, uint timeout /* ms */)
+               {
+                       int last_id = 0;
+                       if (!main_last_id.ContainsKey(name))
+                               main_last_id.Add(name, 0);
+                       else {
+                               last_id = ++main_last_id[name];
+                               main_last_id[name] = last_id;
+                       }
+                       
+                       GLib.Timeout.Add(timeout, delegate { if 
(main_last_id[name] == last_id) func(); return false; } );
+        }
+
                public static Type load<Type>(string filename)
                {
                        Type loaded = default(Type);
@@ -85,7 +111,7 @@
                        
                        return lists;
                }
-
+               
         public static T[] to_array<T>(List<T> list)
         {
             T[] t = new T[list.Count];

Modified: trunk/gtk/FixedResizeWidget.cs
==============================================================================
--- trunk/gtk/FixedResizeWidget.cs      (original)
+++ trunk/gtk/FixedResizeWidget.cs      Mon Jan  7 10:37:42 2008
@@ -6,6 +6,8 @@
 {
        public class FixedResizeWidget : Fixed
        {
+               private static int unique_id = 0;
+
                private static int line_height = 22;
                
                private static double spacing;
@@ -15,8 +17,12 @@
                public VoidFunction<CalendarDriver.View, DateTime> 
update_view_set_next;
                public Function<int[]> calendar_rectangle;
                
+               int id;
+               
                public FixedResizeWidget(double s, bool top_start) : base()
                {
+                       id = ++unique_id;
+               
                        spacing = s;
                        start_at_top = top_start;
 
@@ -118,9 +124,18 @@
                {
                        base.OnSizeAllocated(allocation);
 
+                       Helpers.RunOnlyOnceInMainLIFO(id.ToString(), delegate { 
size_changed(allocation); }, 100);
+               }
+               
+               private void size_changed(Gdk.Rectangle allocation)
+               {
+                       System.Console.WriteLine("size changed");
+               
                        if (allocation.Height == last_allocation.Height && 
allocation.Width == last_allocation.Width)
                                return;
 
+                       System.Console.WriteLine("go go gadget");
+
                        last_allocation = allocation;
 
                        foreach (Widget i in Children) 

Modified: trunk/metadata/MetadataStore.cs
==============================================================================
--- trunk/metadata/MetadataStore.cs     (original)
+++ trunk/metadata/MetadataStore.cs     Mon Jan  7 10:37:42 2008
@@ -499,7 +499,7 @@
 
                 bool is_in_query = database.file_path_is_in_query(path, 
current_query);
                 if (is_in_query || was_in_query != is_in_query)
-                    Helpers.RunOnlyOnce(trigger_query_result_changed, 100);
+                    db_schedule_query_result_update();
             }
             catch (System.IO.FileNotFoundException) {
                 // these are ok
@@ -537,7 +537,7 @@
         
         private void db_schedule_query_result_update()
         {
-                       Helpers.RunOnlyOnce(trigger_query_result_changed, 100); 
       
+                       Helpers.RunOnlyOnceFIFO(trigger_query_result_changed, 
100);        
         }
 
         private void db_handle_rename(RenamedEventArgs e)
_______________________________________________
SVN-commits-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/svn-commits-list

Reply via email to