[gcalctool] Only show "Calculating" status text after some time



commit 52ec4a6ec649cf59d021b019c7e1ede56b657da1
Author: Robin Sonefors <ozamosi flukkost nu>
Date:   Wed Oct 13 09:09:52 2010 +0200

    Only show "Calculating" status text after some time
    
    Having it flash even for small numbers is annoying, when there isn't
    really any wait.

 src/math-equation.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/math-equation.c b/src/math-equation.c
index 7d771e3..fae19df 100644
--- a/src/math-equation.c
+++ b/src/math-equation.c
@@ -985,6 +985,15 @@ math_equation_solve_real(gpointer data)
 }
 
 static gboolean
+math_equation_show_in_progress(gpointer data)
+{
+    MathEquation *equation = MATH_EQUATION(data);
+    if (equation->priv->in_solve)
+        math_equation_set_status(equation, "Calculating");
+    return false;
+}
+
+static gboolean
 math_equation_look_for_answer(gpointer data)
 {
     MathEquation *equation = MATH_EQUATION(data);
@@ -1036,7 +1045,6 @@ math_equation_solve(MathEquation *equation)
     }
 
     equation->priv->in_solve = true;
-    math_equation_set_status(equation, "Calculating");
 
     math_equation_set_number_mode(equation, NORMAL);
 
@@ -1045,7 +1053,8 @@ math_equation_solve(MathEquation *equation)
     if (error)
         g_warning("Error spawning thread for calculations: %s\n", error->message);
 
-    g_timeout_add(100, math_equation_look_for_answer, equation);
+    g_timeout_add(50, math_equation_look_for_answer, equation);
+    g_timeout_add(100, math_equation_show_in_progress, equation);
 }
 
 
@@ -1101,14 +1110,14 @@ math_equation_factorize(MathEquation *equation)
     }
 
     equation->priv->in_solve = true;
-    math_equation_set_status(equation, "Calculating");
 
     g_thread_create(math_equation_factorize_real, equation, false, &error);
 
     if (error)
         g_warning("Error spawning thread for calculations: %s\n", error->message);
 
-    g_timeout_add(100, math_equation_look_for_answer, equation);
+    g_timeout_add(50, math_equation_look_for_answer, equation);
+    g_timeout_add(100, math_equation_show_in_progress, equation);
 }
 
 



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