[latexila] Build tool runner: remove Gtk.Action parameter



commit 9bdbe2764b724bbd9bcd14724ac1820a9605a09d
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Wed Jul 11 02:59:50 2012 +0200

    Build tool runner: remove Gtk.Action parameter
    
    I think the purpose was to set the Gtk.Action as insensitive directly,
    without passing by a signal (here the 'finished' signal), to be more
    efficient. There was probably a problem: when we click to abort the
    build tool, the button was not set as insensitive directly, so we could
    click several times on the abort button. Now the problem seems to be
    gone.

 src/build_tool_runner.vala |   13 ++++---------
 src/main_window.vala       |   27 ++++++++++++---------------
 2 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/src/build_tool_runner.vala b/src/build_tool_runner.vala
index c81f34f..7768678 100644
--- a/src/build_tool_runner.vala
+++ b/src/build_tool_runner.vala
@@ -24,7 +24,6 @@ public class BuildToolRunner : GLib.Object
     private BuildTool _tool;
     private File _on_file;
     private BuildView _view;
-    private Gtk.Action _action_stop_exec;
 
     private TreeIter _main_title;
 
@@ -37,13 +36,11 @@ public class BuildToolRunner : GLib.Object
 
     public signal void finished ();
 
-    public BuildToolRunner (BuildTool build_tool, File on_file, BuildView build_view,
-        Gtk.Action action_stop_exec)
+    public BuildToolRunner (BuildTool build_tool, File on_file, BuildView build_view)
     {
         _tool = build_tool;
         _on_file = on_file;
         _view = build_view;
-        _action_stop_exec = action_stop_exec;
 
         if (! match_allowed_extensions ())
         {
@@ -52,8 +49,6 @@ public class BuildToolRunner : GLib.Object
         }
 
         _view.clear ();
-        _action_stop_exec.set_sensitive (true);
-
         _main_title = _view.add_main_title (_tool.label, BuildState.RUNNING);
 
         _job_num = 0;
@@ -65,11 +60,11 @@ public class BuildToolRunner : GLib.Object
         if (_current_job_runner != null)
             _current_job_runner.abort ();
 
-        _action_stop_exec.set_sensitive (false);
         _view.set_title_state (_main_title, BuildState.ABORTED);
         _view.set_title_state (_current_job_title, BuildState.ABORTED);
 
         _aborted = true;
+        finished ();
     }
 
     private bool match_allowed_extensions ()
@@ -91,7 +86,6 @@ public class BuildToolRunner : GLib.Object
         if (_tool.jobs.size <= _job_num)
         {
             _view.set_title_state (_main_title, BuildState.SUCCEEDED);
-            _action_stop_exec.set_sensitive (false);
             finished ();
             return;
         }
@@ -190,6 +184,7 @@ public class BuildToolRunner : GLib.Object
     {
         _view.set_title_state (_main_title, BuildState.FAILED);
         _view.set_title_state (_current_job_title, BuildState.FAILED);
-        _action_stop_exec.set_sensitive (false);
+
+        finished ();
     }
 }
diff --git a/src/main_window.vala b/src/main_window.vala
index 990278c..df1cde4 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -203,7 +203,6 @@ public class MainWindow : Window
     private uint documents_list_menu_ui_id;
     private uint build_tools_menu_ui_id;
     private BuildToolRunner build_tool_runner;
-    private Gtk.Action action_stop_exec;
 
     // context id for the statusbar
     private uint tip_message_cid;
@@ -298,7 +297,7 @@ public class MainWindow : Window
         search_and_replace = new SearchAndReplace (this);
 
         // bottom panel
-        action_stop_exec = action_group.get_action ("BuildStopExecution");
+        Gtk.Action action_stop_exec = action_group.get_action ("BuildStopExecution");
         action_stop_exec.set_sensitive (false);
 
         _build_view = new BuildView (this);
@@ -1248,23 +1247,21 @@ public class MainWindow : Window
             Utils.flush_queue ();
         }
 
+        Gtk.Action action_stop_exec = action_group.get_action ("BuildStopExecution");
+        action_stop_exec.sensitive = true;
+
         File main_file = active_document.get_main_file ();
-        build_tool_runner = new BuildToolRunner (tool, main_file, _build_view,
-            action_stop_exec);
+        build_tool_runner = new BuildToolRunner (tool, main_file, _build_view);
 
-        // refresh file browser when compilation is finished
-        if (tool.compilation)
+        build_tool_runner.finished.connect (() =>
         {
-            build_tool_runner.finished.connect (() =>
-            {
-                file_browser.refresh_for_document (active_document);
-            });
-        }
-    }
+            action_stop_exec.sensitive = false;
 
-    public Gtk.Action get_action_stop_exec ()
-    {
-        return action_stop_exec;
+            // Refresh the file browser when the compilation is finished.
+            // TODO It would be better if the file browser could detect file updates.
+            if (tool.compilation)
+                file_browser.refresh_for_document (active_document);
+        });
     }
 
     private void update_documents_list_menu ()



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