[latexila] Build Tools: update sensitivity of the "show details" action



commit d08fbe35a545cf1267a9e89d7f17d0c7d0d4f841
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Sun Jul 15 20:38:00 2012 +0200

    Build Tools: update sensitivity of the "show details" action

 src/build_job_runner.vala  |   16 ++++++++++++++++
 src/build_tool_runner.vala |   27 +++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/src/build_job_runner.vala b/src/build_job_runner.vala
index b698af6..f5fc0ee 100644
--- a/src/build_job_runner.vala
+++ b/src/build_job_runner.vala
@@ -81,6 +81,14 @@ public class BuildJobRunner : GLib.Object
             _command_runner.execute_with_output ();
     }
 
+    public bool has_details ()
+    {
+        if (_post_processor == null)
+            return false;
+        else
+            return _post_processor.has_details ();
+    }
+
     public Node<BuildMsg?> get_messages ()
     {
         if (_post_processor == null)
@@ -93,6 +101,14 @@ public class BuildJobRunner : GLib.Object
         return _post_processor.get_messages ();
     }
 
+    public Node<BuildMsg?> get_detailed_messages ()
+    {
+        if (_post_processor == null)
+            return get_messages ();
+        else
+            return _post_processor.get_detailed_messages ();
+    }
+
     public void abort ()
     {
         if (_command_runner != null)
diff --git a/src/build_tool_runner.vala b/src/build_tool_runner.vala
index 8026e61..9be563c 100644
--- a/src/build_tool_runner.vala
+++ b/src/build_tool_runner.vala
@@ -27,11 +27,16 @@ public class BuildToolRunner : GLib.Object
 
     private TreeIter _main_title;
 
+    // Used during the execution
     private int _job_num = 0;
     private BuildJob _current_job;
     private TreeIter? _current_job_title = null;
     private BuildJobRunner? _current_job_runner = null;
 
+    // Keep references
+    private TreeIter[] _job_titles = {};
+    private BuildJobRunner[] _job_runners = {};
+
     private bool _aborted = false;
 
     public signal void finished ();
@@ -43,7 +48,23 @@ public class BuildToolRunner : GLib.Object
         _view = build_view;
 
         _view.clear ();
+        _view.has_details = false;
         _main_title = _view.add_main_title (_tool.label, BuildState.RUNNING);
+
+        /* Update the "has-details" property of the build view (which in turn determines
+         * the sensitivity of the "show details" action).
+         */
+        finished.connect (() =>
+        {
+            foreach (BuildJobRunner job_runner in _job_runners)
+            {
+                if (job_runner.has_details ())
+                {
+                    _view.has_details = true;
+                    return;
+                }
+            }
+        });
     }
 
     public void abort ()
@@ -62,6 +83,12 @@ public class BuildToolRunner : GLib.Object
 
     public void run ()
     {
+        if (_job_num > 0)
+        {
+            _job_titles += _current_job_title;
+            _job_runners += _current_job_runner;
+        }
+
         _current_job_runner = null;
 
         // Run the next job.



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