[latexila/wip/build-tools-revamp] LatexilaPostProcessorAllOutput



commit b83e7d3fe253902dfeb069ff411cc9093a257c3c
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Apr 18 21:51:35 2014 +0200

    LatexilaPostProcessorAllOutput

 src/liblatexila/Makefile.am                        |    8 +-
 .../latexila-post-processor-all-output.c           |  119 ++++++++++++++++++++
 .../latexila-post-processor-all-output.h           |   53 +++++++++
 src/liblatexila/latexila-post-processor.c          |    6 +
 src/liblatexila/latexila-post-processor.h          |   10 +-
 5 files changed, 189 insertions(+), 7 deletions(-)
---
diff --git a/src/liblatexila/Makefile.am b/src/liblatexila/Makefile.am
index c3c190a..78f7716 100644
--- a/src/liblatexila/Makefile.am
+++ b/src/liblatexila/Makefile.am
@@ -1,7 +1,9 @@
 noinst_LTLIBRARIES = liblatexila.la
 
-liblatexila_la_SOURCES =               \
-       latexila-post-processor.c       \
-       latexila-post-processor.h
+liblatexila_la_SOURCES =                       \
+       latexila-post-processor.c               \
+       latexila-post-processor.h               \
+       latexila-post-processor-all-output.c    \
+       latexila-post-processor-all-output.h
 
 -include $(top_srcdir)/git.mk
diff --git a/src/liblatexila/latexila-post-processor-all-output.c 
b/src/liblatexila/latexila-post-processor-all-output.c
new file mode 100644
index 0000000..3aac5db
--- /dev/null
+++ b/src/liblatexila/latexila-post-processor-all-output.c
@@ -0,0 +1,119 @@
+/*
+ * This file is part of LaTeXila.
+ *
+ * Copyright (C) 2014 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * LaTeXila is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LaTeXila is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "latexila-post-processor-all-output.h"
+
+typedef struct _LatexilaPostProcessorAllOutputPrivate LatexilaPostProcessorAllOutputPrivate;
+
+struct _LatexilaPostProcessorAllOutputPrivate
+{
+  GSList *messages;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (LatexilaPostProcessorAllOutput, latexila_post_processor_all_output, 
LATEXILA_TYPE_POST_PROCESSOR)
+
+static void
+latexila_post_processor_all_output_process (LatexilaPostProcessor *post_processor,
+                                            const gchar           *output)
+{
+  LatexilaPostProcessorAllOutputPrivate *priv;
+  gchar **lines;
+  gchar **l;
+
+  priv = latexila_post_processor_all_output_get_instance_private (LATEXILA_POST_PROCESSOR_ALL_OUTPUT 
(post_processor));
+
+  lines = g_strsplit (output, "\n", 0);
+
+  for (l = lines; l != NULL && *l != NULL; l++)
+    {
+      priv->messages = g_slist_prepend (priv->messages, *l);
+    }
+
+  /* Generally a single \n is present at the end of the output, so an empty line
+   * is added to the list. But we don't want to display it.
+   * TODO check if it is still the case in C.
+   */
+#if 0
+  if (priv->messages != NULL)
+    {
+      gchar *line = priv->messages->data;
+      g_assert (line != NULL);
+
+      if (line[0] == '\0')
+        {
+          GSList *removed_element = priv->messages;
+
+          priv->messages = g_slist_remove_link (priv->messages, priv->messages);
+
+          g_slist_free_full (removed_element, g_free);
+        }
+    }
+#endif
+
+  priv->messages = g_slist_reverse (priv->messages);
+
+  /* Do not use g_strfreev() because the strings are reused in the list. */
+  g_free (lines);
+}
+
+static GSList *
+latexila_post_processor_all_output_get_messages (LatexilaPostProcessor *post_processor)
+{
+  LatexilaPostProcessorAllOutputPrivate *priv;
+
+  priv = latexila_post_processor_all_output_get_instance_private (LATEXILA_POST_PROCESSOR_ALL_OUTPUT 
(post_processor));
+
+  return priv->messages;
+}
+
+static void
+latexila_post_processor_all_output_finalize (GObject *object)
+{
+  LatexilaPostProcessorAllOutputPrivate *priv;
+
+  priv = latexila_post_processor_all_output_get_instance_private (LATEXILA_POST_PROCESSOR_ALL_OUTPUT 
(object));
+
+  g_slist_free_full (priv->messages, g_free);
+  priv->messages = NULL;
+
+  G_OBJECT_CLASS (latexila_post_processor_all_output_parent_class)->finalize (object);
+}
+
+static void
+latexila_post_processor_all_output_class_init (LatexilaPostProcessorAllOutputClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  LatexilaPostProcessorClass *post_processor_class = LATEXILA_POST_PROCESSOR_CLASS (klass);
+
+  object_class->finalize = latexila_post_processor_all_output_finalize;
+
+  post_processor_class->process = latexila_post_processor_all_output_process;
+  post_processor_class->get_messages = latexila_post_processor_all_output_get_messages;
+}
+
+static void
+latexila_post_processor_all_output_init (LatexilaPostProcessorAllOutput *self)
+{
+}
+
+LatexilaPostProcessor *
+latexila_post_processor_all_output_new (void)
+{
+  return g_object_new (LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT, NULL);
+}
diff --git a/src/liblatexila/latexila-post-processor-all-output.h 
b/src/liblatexila/latexila-post-processor-all-output.h
new file mode 100644
index 0000000..37127df
--- /dev/null
+++ b/src/liblatexila/latexila-post-processor-all-output.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of LaTeXila.
+ *
+ * Copyright (C) 2014 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * LaTeXila is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LaTeXila is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __LATEXILA_POST_PROCESSOR_ALL_OUTPUT_H__
+#define __LATEXILA_POST_PROCESSOR_ALL_OUTPUT_H__
+
+#include "latexila-post-processor.h"
+
+G_BEGIN_DECLS
+
+#define LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT             (latexila_post_processor_all_output_get_type ())
+#define LATEXILA_POST_PROCESSOR_ALL_OUTPUT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT, LatexilaPostProcessorAllOutput))
+#define LATEXILA_POST_PROCESSOR_ALL_OUTPUT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), 
LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT, LatexilaPostProcessorAllOutputClass))
+#define LATEXILA_IS_POST_PROCESSOR_ALL_OUTPUT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT))
+#define LATEXILA_IS_POST_PROCESSOR_ALL_OUTPUT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), 
LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT))
+#define LATEXILA_POST_PROCESSOR_ALL_OUTPUT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), 
LATEXILA_TYPE_POST_PROCESSOR_ALL_OUTPUT, LatexilaPostProcessorAllOutputClass))
+
+typedef struct _LatexilaPostProcessorAllOutput      LatexilaPostProcessorAllOutput;
+typedef struct _LatexilaPostProcessorAllOutputClass LatexilaPostProcessorAllOutputClass;
+
+struct _LatexilaPostProcessorAllOutput
+{
+  LatexilaPostProcessor parent;
+};
+
+struct _LatexilaPostProcessorAllOutputClass
+{
+  LatexilaPostProcessorClass parent_class;
+};
+
+GType                   latexila_post_processor_all_output_get_type (void) G_GNUC_CONST;
+
+LatexilaPostProcessor * latexila_post_processor_all_output_new      (void);
+
+G_END_DECLS
+
+#endif /* __LATEXILA_POST_PROCESSOR_ALL_OUTPUT_H__ */
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index 920ca24..6a55f6c 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -144,6 +144,12 @@ latexila_post_processor_init (LatexilaPostProcessor *post_processor)
 {
 }
 
+LatexilaPostProcessor *
+latexila_post_processor_new (void)
+{
+  return g_object_new (LATEXILA_TYPE_POST_PROCESSOR, NULL);
+}
+
 void
 latexila_post_processor_process (LatexilaPostProcessor *post_processor,
                                  const gchar           *output)
diff --git a/src/liblatexila/latexila-post-processor.h b/src/liblatexila/latexila-post-processor.h
index f923f5b..2dbc4e7 100644
--- a/src/liblatexila/latexila-post-processor.h
+++ b/src/liblatexila/latexila-post-processor.h
@@ -50,12 +50,14 @@ struct _LatexilaPostProcessorClass
   GSList * (* get_messages) (LatexilaPostProcessor *post_processor);
 };
 
-GType     latexila_post_processor_get_type      (void) G_GNUC_CONST;
+GType                   latexila_post_processor_get_type      (void) G_GNUC_CONST;
 
-void      latexila_post_processor_process       (LatexilaPostProcessor *post_processor,
-                                                 const gchar           *output);
+LatexilaPostProcessor * latexila_post_processor_new           (void);
 
-GSList *  latexila_post_processor_get_messages  (LatexilaPostProcessor *post_processor);
+void                    latexila_post_processor_process       (LatexilaPostProcessor *post_processor,
+                                                               const gchar           *output);
+
+GSList *                latexila_post_processor_get_messages  (LatexilaPostProcessor *post_processor);
 
 G_END_DECLS
 


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