[latexila] Build Tools: more build message types



commit edfbbcca3a1c58476687bde1f1bc8a64e4d9bba7
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Tue Jul 10 00:12:42 2012 +0200

    Build Tools: more build message types
    
    And various cleanup.

 src/build_tool_runner.vala    |    4 +-
 src/build_view.vala           |   89 ++++++++++++++++++++++-------------------
 src/latex_post_processor.vala |    6 +-
 src/post_processors.vala      |    6 +-
 4 files changed, 56 insertions(+), 49 deletions(-)
---
diff --git a/src/build_tool_runner.vala b/src/build_tool_runner.vala
index acc4416..7c9a16f 100644
--- a/src/build_tool_runner.vala
+++ b/src/build_tool_runner.vala
@@ -102,7 +102,7 @@ public class BuildToolRunner : GLib.Object
                 view.append_single_message (job_partition, message);
 
                 message.text = e.message;
-                message.type = BuildMsgType.OTHER;
+                message.type = BuildMsgType.INFO;
                 view.append_single_message (job_partition, message);
 
                 failed ();
@@ -245,7 +245,7 @@ public class BuildToolRunner : GLib.Object
                 BuildMsg info_msg = BuildMsg ();
                 info_msg.text =
                     _("%s doesn't seem to be installed.").printf (command[0]);
-                info_msg.type = BuildMsgType.OTHER;
+                info_msg.type = BuildMsgType.INFO;
                 info_msg.lines_set = false;
                 view.append_single_message (job_partitions[job_num], info_msg);
             }
diff --git a/src/build_view.vala b/src/build_view.vala
index 9681936..0dcab82 100644
--- a/src/build_view.vala
+++ b/src/build_view.vala
@@ -1,7 +1,7 @@
 /*
  * This file is part of LaTeXila.
  *
- * Copyright  2010-2011 SÃbastien Wilmet
+ * Copyright  2010-2012 SÃbastien Wilmet
  *
  * LaTeXila is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,6 +15,8 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: SÃbastien Wilmet
  */
 
 using Gtk;
@@ -29,10 +31,13 @@ public enum PartitionState
 
 public enum BuildMsgType
 {
+    TITLE,
+    JOB_TITLE,
+    JOB_SUB_COMMAND,
     ERROR,
     WARNING,
     BADBOX,
-    OTHER
+    INFO
 }
 
 public struct BuildMsg
@@ -102,14 +107,16 @@ public class BuildView : Grid
         _filtered_model.set_visible_func ((model, iter) =>
         {
             BuildMsgType msg_type;
-            model.get (iter, BuildInfo.MESSAGE_TYPE, out msg_type, -1);
+            model.get (iter, BuildInfo.MESSAGE_TYPE, out msg_type);
 
             switch (msg_type)
             {
                 case BuildMsgType.WARNING:
                     return show_warnings;
+
                 case BuildMsgType.BADBOX:
                     return show_badboxes;
+
                 default:
                     return true;
             }
@@ -193,40 +200,30 @@ public class BuildView : Grid
             // the row is not selected
             return false;
 
-        BuildMsgType msg_type;
+        if (model.iter_has_child (iter))
+        {
+            if (_view.is_row_expanded (path))
+                _view.collapse_row (path);
+            else
+                _view.expand_to_path (path);
+
+            // the row is not selected
+            return false;
+        }
+
         File file;
-        int start_line, end_line;
+        int start_line;
+        int end_line;
 
         model.get (iter,
-            BuildInfo.MESSAGE_TYPE, out msg_type,
             BuildInfo.FILE, out file,
             BuildInfo.START_LINE, out start_line,
-            BuildInfo.END_LINE, out end_line,
-            -1);
+            BuildInfo.END_LINE, out end_line
+        );
 
-        if (msg_type != BuildMsgType.OTHER && file != null)
-        {
+        if (file != null)
             jump_to_file (file, start_line, end_line);
 
-            // the row is selected
-            return true;
-        }
-
-        // maybe it's a parent, so we can show or hide its children
-        else if (msg_type == BuildMsgType.OTHER)
-        {
-            if (model.iter_has_child (iter))
-            {
-                if (_view.is_row_expanded (path))
-                    _view.collapse_row (path);
-                else
-                    _view.expand_to_path (path);
-
-                // the row is not selected
-                return false;
-            }
-        }
-
         // the row is selected, so we can copy/paste its content
         return true;
     }
@@ -256,14 +253,16 @@ public class BuildView : Grid
     public TreeIter add_partition (string msg, PartitionState state, TreeIter? parent,
         bool bold = false)
     {
+        BuildMsgType type = bold ? BuildMsgType.TITLE : BuildMsgType.JOB_TITLE;
+
         TreeIter iter;
         _store.append (out iter, parent);
         _store.set (iter,
             BuildInfo.ICON,         get_icon_from_state (state),
             BuildInfo.MESSAGE,      msg,
-            BuildInfo.MESSAGE_TYPE, BuildMsgType.OTHER,
-            BuildInfo.WEIGHT,       bold ? 800 : 400,
-            -1);
+            BuildInfo.MESSAGE_TYPE, type,
+            BuildInfo.WEIGHT,       bold ? 800 : 400
+        );
 
         _view.expand_to_path (_store.get_path (iter));
 
@@ -272,7 +271,7 @@ public class BuildView : Grid
 
     public void set_partition_state (TreeIter partition_id, PartitionState state)
     {
-        _store.set (partition_id, BuildInfo.ICON, get_icon_from_state (state), -1);
+        _store.set (partition_id, BuildInfo.ICON, get_icon_from_state (state));
     }
 
     public void append_messages (TreeIter parent, Node<BuildMsg?> messages,
@@ -286,7 +285,6 @@ public class BuildView : Grid
             // the node contains children
             if (cur_node.children != null)
             {
-                _store.set (child, BuildInfo.ICON, "completion_choice", -1);
                 append_messages (child, cur_node, false);
 
                 if (cur_node.data.expand)
@@ -302,7 +300,7 @@ public class BuildView : Grid
             _view.expand_row (_store.get_path (parent), false);
     }
 
-    public TreeIter append_single_message (TreeIter partition_id, BuildMsg message)
+    public TreeIter append_single_message (TreeIter parent, BuildMsg message)
     {
         File file = null;
         string path = null;
@@ -327,7 +325,7 @@ public class BuildView : Grid
         }
 
         TreeIter iter;
-        _store.append (out iter, partition_id);
+        _store.append (out iter, parent);
         _store.set (iter,
             BuildInfo.ICON,         get_icon_from_msg_type (message.type),
             BuildInfo.MESSAGE,      message.text,
@@ -338,8 +336,8 @@ public class BuildView : Grid
             BuildInfo.PATH,         path,
             BuildInfo.START_LINE,   start_line,
             BuildInfo.END_LINE,     end_line,
-            BuildInfo.LINE,         line_str,
-            -1);
+            BuildInfo.LINE,         line_str
+        );
 
         return iter;
     }
@@ -350,12 +348,16 @@ public class BuildView : Grid
         {
             case PartitionState.RUNNING:
                 return Stock.EXECUTE;
+
             case PartitionState.SUCCEEDED:
                 return Stock.APPLY;
+
             case PartitionState.FAILED:
                 return Stock.DIALOG_ERROR;
+
             case PartitionState.ABORTED:
                 return Stock.STOP;
+
             default:
                 return_val_if_reached (null);
         }
@@ -365,16 +367,21 @@ public class BuildView : Grid
     {
         switch (type)
         {
+            case BuildMsgType.JOB_SUB_COMMAND:
+                // TODO rename the completion_choice stock icon
+                return "completion_choice";
+
             case BuildMsgType.ERROR:
                 return Stock.DIALOG_ERROR;
+
             case BuildMsgType.WARNING:
                 return Stock.DIALOG_WARNING;
+
             case BuildMsgType.BADBOX:
                 return "badbox";
-            case BuildMsgType.OTHER:
-                return null;
+
             default:
-                return_val_if_reached (null);
+                return null;
         }
     }
 
diff --git a/src/latex_post_processor.vala b/src/latex_post_processor.vala
index 7e532b8..f74eeb1 100644
--- a/src/latex_post_processor.vala
+++ b/src/latex_post_processor.vala
@@ -145,7 +145,7 @@ private class LatexPostProcessor : PostProcessor
             nb_errors,   nb_errors   == 1 ? "error"   : "errors",
             nb_warnings, nb_warnings == 1 ? "warning" : "warnings",
             nb_badboxes, nb_badboxes == 1 ? "badbox"  : "badboxes");
-        msg.type = BuildMsgType.OTHER;
+        msg.type = BuildMsgType.INFO;
         add_msg (false);
     }
 
@@ -482,7 +482,7 @@ private class LatexPostProcessor : PostProcessor
             return false;
 
         msg.start_line = NO_LINE;
-        msg.type = BuildMsgType.OTHER;
+        msg.type = BuildMsgType.INFO;
 
         MatchInfo match_info;
         if (! reg_other_bytes.match (line, 0, out match_info))
@@ -835,7 +835,7 @@ private class LatexPostProcessor : PostProcessor
     {
         msg = BuildMsg ();
         msg.text = null;
-        msg.type = BuildMsgType.OTHER;
+        msg.type = BuildMsgType.INFO;
         msg.filename = null;
         msg.start_line = NO_LINE;
         msg.end_line = NO_LINE;
diff --git a/src/post_processors.vala b/src/post_processors.vala
index 878d7d6..4cbcc7d 100644
--- a/src/post_processors.vala
+++ b/src/post_processors.vala
@@ -83,7 +83,7 @@ private class AllOutputPostProcessor : PostProcessor
             nb_lines--;
 
         BuildMsg message = BuildMsg ();
-        message.type = BuildMsgType.OTHER;
+        message.type = BuildMsgType.INFO;
         message.filename = null;
         message.lines_set = false;
 
@@ -245,7 +245,7 @@ private class LatexmkPostProcessor : PostProcessor
 
             /* title */
             BuildMsg title_msg = BuildMsg ();
-            title_msg.type = BuildMsgType.OTHER;
+            title_msg.type = BuildMsgType.JOB_SUB_COMMAND;
             title_msg.lines_set = false;
             title_msg.text = match_info.fetch_named ("title");
 
@@ -257,7 +257,7 @@ private class LatexmkPostProcessor : PostProcessor
 
             /* command line */
             BuildMsg cmd_line_msg = BuildMsg ();
-            cmd_line_msg.type = BuildMsgType.OTHER;
+            cmd_line_msg.type = BuildMsgType.INFO;
             cmd_line_msg.lines_set = false;
             cmd_line_msg.text = "$ " + match_info.fetch_named ("cmd");
 



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