[latexila/wip/latexila-next: 1/2] PostProcessor: public functions for the vfuncs



commit e1e6c4458b99c7529f2743a522320126a35f6066
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Sep 29 23:10:56 2014 +0200

    PostProcessor: public functions for the vfuncs

 docs/reference/latexila-sections.txt      |    3 +
 src/liblatexila/latexila-post-processor.c |   66 ++++++++++++++++++++++++++---
 src/liblatexila/latexila-post-processor.h |   18 ++++----
 3 files changed, 71 insertions(+), 16 deletions(-)
---
diff --git a/docs/reference/latexila-sections.txt b/docs/reference/latexila-sections.txt
index a589d6c..199f43e 100644
--- a/docs/reference/latexila-sections.txt
+++ b/docs/reference/latexila-sections.txt
@@ -143,6 +143,9 @@ latexila_post_processor_get_name_from_type
 latexila_post_processor_get_type_from_name
 latexila_post_processor_process_async
 latexila_post_processor_process_finish
+latexila_post_processor_start
+latexila_post_processor_process_line
+latexila_post_processor_end
 latexila_post_processor_get_messages
 <SUBSECTION Standard>
 LATEXILA_IS_POST_PROCESSOR
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index f72cc9e..5fe1eaa 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -323,7 +323,7 @@ read_stream_cb (GInputStream          *stream,
           line = g_string_free (pp->priv->line_buffer, FALSE);
           pp->priv->line_buffer = NULL;
 
-          LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->process_line (pp, line);
+          latexila_post_processor_process_line (pp, line);
         }
 
       /* finished! */
@@ -366,7 +366,7 @@ read_stream_cb (GInputStream          *stream,
       lines[last_line] = NULL;
 
       for (i = 0; lines[i] != NULL; i++)
-        LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->process_line (pp, lines[i]);
+        latexila_post_processor_process_line (pp, lines[i]);
 
       g_free (lines);
     }
@@ -428,7 +428,7 @@ latexila_post_processor_process_async (LatexilaPostProcessor *pp,
   pp->priv->task = g_task_new (pp, cancellable, callback, user_data);
   pp->priv->stream = g_object_ref (stream);
 
-  LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->start (pp, file);
+  latexila_post_processor_start (pp, file);
 
   if (pp->priv->line_buffer != NULL)
     {
@@ -456,7 +456,7 @@ latexila_post_processor_process_finish (LatexilaPostProcessor *pp,
 
   g_task_propagate_boolean (G_TASK (result), NULL);
 
-  LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->end (pp);
+  latexila_post_processor_end (pp);
 
   g_clear_object (&pp->priv->task);
   g_clear_object (&pp->priv->stream);
@@ -469,11 +469,64 @@ latexila_post_processor_process_finish (LatexilaPostProcessor *pp,
 }
 
 /**
+ * latexila_post_processor_start:
+ * @pp: a #LatexilaPostProcessor.
+ * @file: the #GFile on which the build tool is run.
+ *
+ * Manually starts the post-processor.
+ *
+ * Not needed if you use latexila_post_processor_process_async().
+ */
+void
+latexila_post_processor_start (LatexilaPostProcessor *pp,
+                               GFile                 *file)
+{
+  g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (pp));
+
+  return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->start (pp, file);
+}
+
+/**
+ * latexila_post_processor_process_line:
+ * @pp: a #LatexilaPostProcessor.
+ * @line: (transfer full): a line, without the newline character(s).
+ *
+ * Manually processes a line. This function takes ownership of @line. Free with
+ * g_free() if you don't reuse the content.
+ *
+ * Not needed if you use latexila_post_processor_process_async().
+ */
+void
+latexila_post_processor_process_line (LatexilaPostProcessor *pp,
+                                      gchar                 *line)
+{
+  g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (pp));
+
+  return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->process_line (pp, line);
+}
+
+/**
+ * latexila_post_processor_end:
+ * @pp: a #LatexilaPostProcessor.
+ *
+ * Manually ends the processing.
+ *
+ * Not needed if you use latexila_post_processor_process_async().
+ */
+void
+latexila_post_processor_end (LatexilaPostProcessor *pp)
+{
+  g_return_if_fail (LATEXILA_IS_POST_PROCESSOR (pp));
+
+  return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->end (pp);
+}
+
+/**
  * latexila_post_processor_get_messages:
  * @pp: a post-processor.
  *
  * Gets the filtered messages. Call this function only after calling
- * latexila_post_processor_process_finish().
+ * latexila_post_processor_process_finish() or latexila_post_processor_end().
  *
  * Another solution would have been to pass the #LatexilaBuildView to the
  * post-processor, so the filtered messages can directly be outputed to the
@@ -494,7 +547,8 @@ latexila_post_processor_process_finish (LatexilaPostProcessor *pp,
  *
  * The current solution is "good enough". And "good enough" is... "good enough".
  *
- * Returns: the tree of filtered messages.
+ * Returns: (transfer none): the tree of filtered messages. Element types:
+ * #LatexilaBuildMsg.
  */
 const GQueue *
 latexila_post_processor_get_messages (LatexilaPostProcessor *pp)
diff --git a/src/liblatexila/latexila-post-processor.h b/src/liblatexila/latexila-post-processor.h
index e0200fb..4816018 100644
--- a/src/liblatexila/latexila-post-processor.h
+++ b/src/liblatexila/latexila-post-processor.h
@@ -65,24 +65,14 @@ struct _LatexilaPostProcessorClass
 {
   GObjectClass parent_class;
 
-  /* Start of processing.
-   * @file is the GFile on which the build tool is run.
-   */
   void (* start) (LatexilaPostProcessor *pp,
                   GFile                 *file);
 
-  /* The process_line function takes ownership of @line. Free with
-   * g_free() if you don't reuse the content.
-   */
   void (* process_line) (LatexilaPostProcessor *pp,
                          gchar                 *line);
 
-  /* End of processing. */
   void (* end) (LatexilaPostProcessor *pp);
 
-  /* Get the build messages. The elements are of type "LatexilaBuildMsg *".
-   * This function is called after end().
-   */
   const GQueue * (* get_messages) (LatexilaPostProcessor *pp);
 };
 
@@ -103,6 +93,14 @@ void                    latexila_post_processor_process_async         (LatexilaP
 void                    latexila_post_processor_process_finish        (LatexilaPostProcessor *pp,
                                                                        GAsyncResult          *result);
 
+void                    latexila_post_processor_start                 (LatexilaPostProcessor *pp,
+                                                                       GFile                 *file);
+
+void                    latexila_post_processor_process_line          (LatexilaPostProcessor *pp,
+                                                                       gchar                 *line);
+
+void                    latexila_post_processor_end                   (LatexilaPostProcessor *pp);
+
 const GQueue *          latexila_post_processor_get_messages          (LatexilaPostProcessor *pp);
 
 G_END_DECLS


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