[latexila/wip/build-tools-revamp] LatexilaBuildTools class (not finished)



commit 04a113ef31b6d53a86ce91c33e47a5bfe3b497cd
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Apr 19 15:44:23 2014 +0200

    LatexilaBuildTools class (not finished)

 src/liblatexila/Makefile.am            |    4 +
 src/liblatexila/latexila-build-tools.c |  668 ++++++++++++++++++++++++++++++++
 src/liblatexila/latexila-build-tools.h |   94 +++++
 3 files changed, 766 insertions(+), 0 deletions(-)
---
diff --git a/src/liblatexila/Makefile.am b/src/liblatexila/Makefile.am
index 78f7716..bec8f7a 100644
--- a/src/liblatexila/Makefile.am
+++ b/src/liblatexila/Makefile.am
@@ -1,6 +1,10 @@
+AM_CPPFLAGS = $(WARN_CFLAGS)
+
 noinst_LTLIBRARIES = liblatexila.la
 
 liblatexila_la_SOURCES =                       \
+       latexila-build-tools.c                  \
+       latexila-build-tools.h                  \
        latexila-post-processor.c               \
        latexila-post-processor.h               \
        latexila-post-processor-all-output.c    \
diff --git a/src/liblatexila/latexila-build-tools.c b/src/liblatexila/latexila-build-tools.c
new file mode 100644
index 0000000..b053aa8
--- /dev/null
+++ b/src/liblatexila/latexila-build-tools.c
@@ -0,0 +1,668 @@
+/*
+ * 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/>.
+ */
+
+/* Load build tools from an XML file into data structures in memory. The build
+ * tools can be modified in memory, and then saved into the XML file.
+ */
+
+#include "config.h"
+#include "latexila-build-tools.h"
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+
+static LatexilaBuildTools *default_build_tools = NULL;
+static LatexilaBuildTools *personal_build_tools = NULL;
+
+typedef enum
+{
+  LATEXILA_BUILD_TOOLS_TYPE_DEFAULT, /* default build tools */
+  LATEXILA_BUILD_TOOLS_TYPE_PERSONAL /* personal build tools */
+} LatexilaBuildToolsType;
+
+struct _LatexilaBuildToolsPrivate
+{
+  /* A list of LatexilaBuildTool's */
+  GList *build_tools;
+
+  GFile *xml_file;
+
+  LatexilaBuildToolsType build_tools_type;
+
+  /* Used during the XML file parsing to load the build tools. */
+  LatexilaBuildTool *cur_tool;
+  LatexilaBuildJob *cur_job;
+
+  guint modified : 1;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (LatexilaBuildTools, latexila_build_tools, G_TYPE_OBJECT)
+
+static LatexilaBuildJob *
+build_job_new (void)
+{
+  return g_slice_new0 (LatexilaBuildJob);
+}
+
+static void
+build_job_free (LatexilaBuildJob *build_job)
+{
+  if (build_job != NULL)
+    {
+      g_free (build_job->command);
+      g_slice_free (LatexilaBuildJob, build_job);
+    }
+}
+
+static LatexilaBuildTool *
+build_tool_new (void)
+{
+  return g_slice_new0 (LatexilaBuildTool);
+}
+
+static void
+build_tool_free (LatexilaBuildTool *build_tool)
+{
+  if (build_tool != NULL)
+    {
+      g_free (build_tool->label);
+      g_free (build_tool->description);
+      g_free (build_tool->extensions);
+      g_free (build_tool->icon);
+      g_free (build_tool->files_to_open);
+
+      g_slist_free_full (build_tool->jobs, (GDestroyNotify) build_job_free);
+
+      g_slice_free (LatexilaBuildTool, build_tool);
+    }
+}
+
+static const gchar *
+build_tool_get_description (LatexilaBuildTool *build_tool)
+{
+  if (build_tool->description == NULL ||
+      build_tool->description[0] == '\0')
+    {
+      return build_tool->label;
+    }
+
+  return build_tool->description;
+}
+
+static gboolean
+get_post_processor_type_from_name (const gchar               *name,
+                                   LatexilaPostProcessorType *type)
+{
+  g_assert (type != NULL);
+
+  if (g_str_equal (name, "latexmk"))
+    {
+      *type = LATEXILA_POST_PROCESSOR_TYPE_LATEXMK;
+      return TRUE;
+    }
+
+  if (g_str_equal (name, "latex"))
+    {
+      *type = LATEXILA_POST_PROCESSOR_TYPE_LATEX;
+      return TRUE;
+    }
+
+  if (g_str_equal (name, "all-output"))
+    {
+      *type = LATEXILA_POST_PROCESSOR_TYPE_ALL_OUTPUT;
+      return TRUE;
+    }
+
+  if (g_str_equal (name, "no-output"))
+    {
+      *type = LATEXILA_POST_PROCESSOR_TYPE_NO_OUTPUT;
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+static const gchar *
+get_post_processor_name_from_type (LatexilaPostProcessorType type)
+{
+  switch (type)
+    {
+    case LATEXILA_POST_PROCESSOR_TYPE_LATEXMK:
+      return "latexmk";
+
+    case LATEXILA_POST_PROCESSOR_TYPE_LATEX:
+      return "latex";
+
+    case LATEXILA_POST_PROCESSOR_TYPE_ALL_OUTPUT:
+      return "all-output";
+
+    case LATEXILA_POST_PROCESSOR_TYPE_NO_OUTPUT:
+      return "no-output";
+
+    default:
+      g_return_val_if_reached (NULL);
+    }
+}
+
+static void
+latexila_build_tools_dispose (GObject *object)
+{
+  LatexilaBuildTools *build_tools = LATEXILA_BUILD_TOOLS (object);
+
+  g_clear_object (&build_tools->priv->xml_file);
+
+  G_OBJECT_CLASS (latexila_build_tools_parent_class)->dispose (object);
+}
+
+static void
+latexila_build_tools_finalize (GObject *object)
+{
+  LatexilaBuildTools *build_tools = LATEXILA_BUILD_TOOLS (object);
+
+  g_list_free_full (build_tools->priv->build_tools, (GDestroyNotify) build_tool_free);
+  build_tool_free (build_tools->priv->cur_tool);
+  build_job_free (build_tools->priv->cur_job);
+
+  G_OBJECT_CLASS (latexila_build_tools_parent_class)->finalize (object);
+}
+
+static void
+latexila_build_tools_class_init (LatexilaBuildToolsClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->dispose = latexila_build_tools_dispose;
+  object_class->finalize = latexila_build_tools_finalize;
+}
+
+static void
+latexila_build_tools_init (LatexilaBuildTools *self)
+{
+  self->priv = latexila_build_tools_get_instance_private (self);
+}
+
+static LatexilaBuildTools *
+latexila_build_tools_new (GFile                  *xml_file,
+                          LatexilaBuildToolsType  build_tools_type)
+{
+  LatexilaBuildTools *build_tools;
+
+  g_return_val_if_fail (G_IS_FILE (xml_file), NULL);
+
+  build_tools = g_object_new (LATEXILA_TYPE_BUILD_TOOLS, NULL);
+  build_tools->priv->xml_file = g_object_ref (xml_file);
+  build_tools->priv->build_tools_type = build_tools_type;
+
+  return build_tools;
+}
+
+static GFile *
+get_xml_file_default (void)
+{
+  gchar *path;
+  GFile *file;
+
+  path = g_build_filename (DATA_DIR, "build_tools.xml", NULL);
+  file = g_file_new_for_path (path);
+  g_free (path);
+
+  return file;
+}
+
+static GFile *
+get_xml_file_personal (void)
+{
+  gchar *path;
+  GFile *file;
+
+  path = g_build_filename (g_get_user_config_dir (),
+                           "latexila",
+                           "build_tools.xml",
+                           NULL);
+
+  file = g_file_new_for_path (path);
+  g_free (path);
+
+  return file;
+}
+
+LatexilaBuildTools *
+latexila_build_tools_get_default (void)
+{
+  if (default_build_tools == NULL)
+    {
+      GFile *xml_file = get_xml_file_default ();
+      default_build_tools = latexila_build_tools_new (xml_file, LATEXILA_BUILD_TOOLS_TYPE_DEFAULT);
+      g_object_unref (xml_file);
+    }
+
+  return default_build_tools;
+}
+
+LatexilaBuildTools *
+latexila_build_tools_get_personal (void)
+{
+  if (personal_build_tools == NULL)
+    {
+      GFile *xml_file = get_xml_file_personal ();
+      personal_build_tools = latexila_build_tools_new (xml_file, LATEXILA_BUILD_TOOLS_TYPE_PERSONAL);
+      g_object_unref (xml_file);
+    }
+
+  return personal_build_tools;
+}
+
+static void
+parser_start_element (GMarkupParseContext  *context,
+                      const gchar          *element_name,
+                      const gchar         **attribute_names,
+                      const gchar         **attribute_values,
+                      gpointer              user_data,
+                      GError              **error)
+{
+  LatexilaBuildTools *build_tools = user_data;
+
+  if (g_str_equal (element_name, "tools") ||
+      g_str_equal (element_name, "label") ||
+      g_str_equal (element_name, "description") ||
+      g_str_equal (element_name, "open"))
+    {
+      /* do nothing */
+    }
+
+  else if (g_str_equal (element_name, "tool"))
+    {
+      LatexilaBuildTool *cur_tool;
+      gint i;
+
+      build_tool_free (build_tools->priv->cur_tool);
+      cur_tool = build_tool_new ();
+      build_tools->priv->cur_tool = cur_tool;
+
+      for (i = 0; attribute_names[i] != NULL; i++)
+        {
+          if (g_str_equal (attribute_names[i], "id"))
+            {
+              cur_tool->id = g_strtod (attribute_values[i], NULL);
+            }
+          /* "show" was the previous name of "enabled" */
+          else if (g_str_equal (attribute_names[i], "show") ||
+                   g_str_equal (attribute_names[i], "enabled"))
+            {
+              cur_tool->enabled = g_str_equal (attribute_values[i], "true");
+            }
+          else if (g_str_equal (attribute_names[i], "extensions"))
+            {
+              cur_tool->extensions = g_strdup (attribute_values[i]);
+            }
+          else if (g_str_equal (attribute_names[i], "icon"))
+            {
+              cur_tool->icon = g_strdup (attribute_values[i]);
+            }
+          else if (error != NULL)
+            {
+              *error = g_error_new (G_MARKUP_ERROR,
+                                    G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
+                                    "unknown attribute \"%s\"",
+                                    attribute_names[i]);
+            }
+        }
+    }
+
+  else if (g_str_equal (element_name, "job"))
+    {
+      LatexilaBuildJob *cur_job;
+      gint i;
+
+      build_job_free (build_tools->priv->cur_job);
+      cur_job = build_job_new ();
+      build_tools->priv->cur_job = cur_job;
+
+      for (i = 0; attribute_names[i] != NULL; i++)
+        {
+          if (g_str_equal (attribute_names[i], "postProcessor"))
+            {
+              LatexilaPostProcessorType type;
+
+              if (get_post_processor_type_from_name (attribute_values[i], &type))
+                {
+                  cur_job->post_processor_type = type;
+                }
+              else if (error != NULL)
+                {
+                  *error = g_error_new (G_MARKUP_ERROR,
+                                        G_MARKUP_ERROR_INVALID_CONTENT,
+                                        "unknown post processor \"%s\"",
+                                        attribute_values[i]);
+                }
+            }
+
+          /* For compatibility (no longer used) */
+          else if (g_str_equal (attribute_names[i], "mustSucceed"))
+            {
+            }
+
+          else if (error != NULL)
+            {
+              *error = g_error_new (G_MARKUP_ERROR,
+                                    G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
+                                    "unknown attribute \"%s\"",
+                                    attribute_names[i]);
+            }
+        }
+    }
+
+  else if (error != NULL)
+    {
+      *error = g_error_new (G_MARKUP_ERROR,
+                            G_MARKUP_ERROR_UNKNOWN_ELEMENT,
+                            "unknown element \"%s\"",
+                            element_name);
+    }
+}
+
+static void
+parser_end_element (GMarkupParseContext  *context,
+                    const gchar          *element_name,
+                    gpointer              user_data,
+                    GError              **error)
+{
+  LatexilaBuildTools *build_tools = user_data;
+
+  if (g_str_equal (element_name, "tools") ||
+      g_str_equal (element_name, "label") ||
+      g_str_equal (element_name, "description") ||
+      g_str_equal (element_name, "open"))
+    {
+      /* do nothing */
+    }
+
+  else if (g_str_equal (element_name, "tool"))
+    {
+      LatexilaBuildTool *cur_tool = build_tools->priv->cur_tool;
+
+      cur_tool->jobs = g_slist_reverse (cur_tool->jobs);
+
+      build_tools->priv->build_tools = g_list_prepend (build_tools->priv->build_tools,
+                                                       cur_tool);
+
+      build_tools->priv->cur_tool = NULL;
+    }
+
+  else if (g_str_equal (element_name, "job"))
+    {
+      LatexilaBuildTool *cur_tool = build_tools->priv->cur_tool;
+
+      cur_tool->jobs = g_slist_prepend (cur_tool->jobs,
+                                        build_tools->priv->cur_job);
+
+      build_tools->priv->cur_job = NULL;
+    }
+
+  else if (error != NULL)
+    {
+      *error = g_error_new (G_MARKUP_ERROR,
+                            G_MARKUP_ERROR_UNKNOWN_ELEMENT,
+                            "unknown element \"%s\"",
+                            element_name);
+    }
+}
+
+static void
+parser_text (GMarkupParseContext  *context,
+             const gchar          *text,
+             gsize                 text_len,
+             gpointer              user_data,
+             GError              **error)
+{
+  LatexilaBuildTools *build_tools = user_data;
+  const gchar *element_name = g_markup_parse_context_get_element (context);
+  gchar *stripped_text = g_strdup (text);
+  stripped_text = g_strstrip (stripped_text);
+
+  if (g_str_equal (element_name, "job") &&
+      build_tools->priv->cur_job != NULL)
+    {
+      g_free (build_tools->priv->cur_job->command);
+      build_tools->priv->cur_job->command = stripped_text;
+    }
+
+  else if (g_str_equal (element_name, "label") &&
+           build_tools->priv->cur_tool != NULL)
+    {
+      g_free (build_tools->priv->cur_tool->label);
+      build_tools->priv->cur_tool->label = _(stripped_text);
+
+      g_free (stripped_text);
+    }
+
+  else if (g_str_equal (element_name, "description") &&
+           build_tools->priv->cur_tool != NULL)
+    {
+      g_free (build_tools->priv->cur_tool->description);
+      build_tools->priv->cur_tool->description = _(stripped_text);
+
+      g_free (stripped_text);
+    }
+
+  else if (g_str_equal (element_name, "open") &&
+           build_tools->priv->cur_tool != NULL)
+    {
+      g_free (build_tools->priv->cur_tool->files_to_open);
+      build_tools->priv->cur_tool->files_to_open = stripped_text;
+    }
+
+  else
+    {
+      g_free (stripped_text);
+    }
+}
+
+static void
+parse_contents (LatexilaBuildTools *build_tools,
+                gchar              *contents)
+{
+  GMarkupParser parser;
+  GMarkupParseContext *context;
+  GError *error = NULL;
+
+  parser.start_element = parser_start_element;
+  parser.end_element = parser_end_element;
+  parser.text = parser_text;
+  parser.passthrough = NULL;
+  parser.error = NULL;
+
+  context = g_markup_parse_context_new (&parser, 0, build_tools, NULL);
+
+  g_markup_parse_context_parse (context, contents, -1, &error);
+
+  if (error != NULL)
+    {
+      g_warning ("Error while parsing build tools: %s", error->message);
+      g_error_free (error);
+      error = NULL;
+      goto out;
+    }
+
+  g_markup_parse_context_end_parse (context, &error);
+
+  if (error != NULL)
+    {
+      g_warning ("Error while ending build tools parser: %s", error->message);
+      g_error_free (error);
+      error = NULL;
+      goto out;
+    }
+
+out:
+  build_tools->priv->build_tools = g_list_reverse (build_tools->priv->build_tools);
+
+  g_markup_parse_context_free (context);
+  g_free (contents);
+}
+
+static void
+load_contents_cb (GFile              *xml_file,
+                  GAsyncResult       *result,
+                  LatexilaBuildTools *build_tools)
+{
+  gchar *contents = NULL;
+  GError *error = NULL;
+
+  g_file_load_contents_finish (xml_file, result, &contents, NULL, NULL, &error);
+
+  if (error != NULL)
+    {
+      if (error->domain == G_IO_ERROR &&
+          error->code == G_IO_ERROR_NOT_FOUND)
+        {
+          switch (build_tools->priv->build_tools_type)
+            {
+            case LATEXILA_BUILD_TOOLS_TYPE_DEFAULT:
+              g_warning ("XML file not found for the default build tools: %s",
+                         g_file_get_parse_name (xml_file));
+              break;
+
+            case LATEXILA_BUILD_TOOLS_TYPE_PERSONAL:
+              /* No personal build tools. */
+              break;
+
+            default:
+              g_return_if_reached ();
+              break;
+            }
+        }
+      else
+        {
+          g_warning ("Error while loading the contents of the build tools XML file: %s",
+                     error->message);
+        }
+
+      g_error_free (error);
+      return;
+    }
+
+  if (contents != NULL)
+    {
+      parse_contents (build_tools, contents);
+    }
+}
+
+static void
+load (LatexilaBuildTools *build_tools)
+{
+  g_return_if_fail (LATEXILA_IS_BUILD_TOOLS (build_tools));
+  g_return_if_fail (build_tools->priv->xml_file != NULL);
+
+  g_file_load_contents_async (build_tools->priv->xml_file,
+                              NULL,
+                              (GAsyncReadyCallback) load_contents_cb,
+                              build_tools);
+}
+
+static void
+save_cb (GFile        *xml_file,
+         GAsyncResult *result,
+         GString      *contents)
+{
+  GError *error = NULL;
+
+  g_file_replace_contents_finish (xml_file, result, NULL, &error);
+
+  if (error != NULL)
+    {
+      g_warning ("Error while saving the personal build tools: %s",
+                 error->message);
+      g_error_free (error);
+    }
+
+  g_string_free (contents, TRUE);
+}
+
+void
+latexila_build_tools_save (LatexilaBuildTools *build_tools)
+{
+  GString *contents;
+  GList *cur_build_tool;
+
+  g_return_if_fail (LATEXILA_IS_BUILD_TOOLS (build_tools));
+  g_return_if_fail (build_tools->priv->build_tools_type == LATEXILA_BUILD_TOOLS_TYPE_PERSONAL);
+
+  if (!build_tools->priv->modified)
+    {
+      return;
+    }
+
+  contents = g_string_new ("<tools>");
+
+  for (cur_build_tool = build_tools->priv->build_tools;
+       cur_build_tool != NULL;
+       cur_build_tool = cur_build_tool->next)
+    {
+      LatexilaBuildTool *build_tool = cur_build_tool->data;
+      gchar *escaped_text;
+      GSList *cur_build_job;
+
+      g_string_append_printf (contents,
+                              "\n  <tool enabled=\"%s\" extensions=\"%s\" icon=\"%s\">\n",
+                              build_tool->enabled ? "true" : "false",
+                              build_tool->extensions != NULL ? build_tool->extensions : "",
+                              build_tool->icon != NULL ? build_tool->icon : "");
+
+      escaped_text = g_markup_printf_escaped ("    <label>%s</label>\n"
+                                              "    <description>%s</description>\n",
+                                              build_tool->label != NULL ? build_tool->label : "",
+                                              build_tool->description != NULL ? build_tool->description : 
"");
+
+      g_string_append (contents, escaped_text);
+      g_free (escaped_text);
+
+      for (cur_build_job = build_tool->jobs;
+           cur_build_job != NULL;
+           cur_build_job = cur_build_job->next)
+        {
+          LatexilaBuildJob *build_job = cur_build_job->data;
+
+          escaped_text = g_markup_printf_escaped ("    <job postProcessor=\"%s\">%s</job>\n",
+                                                  get_post_processor_name_from_type 
(build_job->post_processor_type),
+                                                  build_job->command != NULL ? build_job->command : "");
+
+          g_string_append (contents, escaped_text);
+          g_free (escaped_text);
+        }
+
+      escaped_text = g_markup_printf_escaped ("    <open>%s</open>\n",
+                                              build_tool->files_to_open != NULL ? build_tool->files_to_open 
: "");
+      g_string_append (contents, escaped_text);
+      g_free (escaped_text);
+
+      g_string_append (contents, "  </tool>\n");
+    }
+
+  g_string_append (contents, "</tools>\n");
+
+  g_file_replace_contents_async (build_tools->priv->xml_file,
+                                 contents->str,
+                                 contents->len,
+                                 NULL,
+                                 TRUE, /* make a backup */
+                                 G_FILE_CREATE_NONE,
+                                 NULL,
+                                 (GAsyncReadyCallback) save_cb,
+                                 contents);
+}
diff --git a/src/liblatexila/latexila-build-tools.h b/src/liblatexila/latexila-build-tools.h
new file mode 100644
index 0000000..4f6bed8
--- /dev/null
+++ b/src/liblatexila/latexila-build-tools.h
@@ -0,0 +1,94 @@
+/*
+ * 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_BUILD_TOOLS_H__
+#define __LATEXILA_BUILD_TOOLS_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define LATEXILA_TYPE_BUILD_TOOLS             (latexila_build_tools_get_type ())
+#define LATEXILA_BUILD_TOOLS(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), LATEXILA_TYPE_BUILD_TOOLS, 
LatexilaBuildTools))
+#define LATEXILA_BUILD_TOOLS_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), LATEXILA_TYPE_BUILD_TOOLS, 
LatexilaBuildToolsClass))
+#define LATEXILA_IS_BUILD_TOOLS(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LATEXILA_TYPE_BUILD_TOOLS))
+#define LATEXILA_IS_BUILD_TOOLS_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), LATEXILA_TYPE_BUILD_TOOLS))
+#define LATEXILA_BUILD_TOOLS_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), LATEXILA_TYPE_BUILD_TOOLS, 
LatexilaBuildToolsClass))
+
+typedef struct _LatexilaBuildTools        LatexilaBuildTools;
+typedef struct _LatexilaBuildToolsClass   LatexilaBuildToolsClass;
+typedef struct _LatexilaBuildToolsPrivate LatexilaBuildToolsPrivate;
+
+struct _LatexilaBuildTools
+{
+  GObject parent;
+
+  LatexilaBuildToolsPrivate *priv;
+};
+
+struct _LatexilaBuildToolsClass
+{
+  GObjectClass parent_class;
+};
+
+typedef enum
+{
+  LATEXILA_POST_PROCESSOR_TYPE_NO_OUTPUT,
+  LATEXILA_POST_PROCESSOR_TYPE_ALL_OUTPUT,
+  LATEXILA_POST_PROCESSOR_TYPE_LATEX,
+  LATEXILA_POST_PROCESSOR_TYPE_LATEXMK
+} LatexilaPostProcessorType;
+
+typedef struct
+{
+  LatexilaPostProcessorType post_processor_type;
+  gchar *command;
+} LatexilaBuildJob;
+
+typedef struct
+{
+  gchar *label;
+  gchar *description;
+  gchar *extensions;
+  gchar *icon;
+  gchar *files_to_open;
+
+  /* A list of LatexilaBuildJob's */
+  GSList *jobs;
+
+  /* The id is used only by the default build tools.
+   * It is used to save those are enabled or disabled.
+   */
+  gint id;
+
+  guint enabled : 1;
+} LatexilaBuildTool;
+
+GType                   latexila_build_tools_get_type         (void) G_GNUC_CONST;
+
+LatexilaBuildTools *    latexila_build_tools_get_default      (void);
+
+LatexilaBuildTools *    latexila_build_tools_get_personal     (void);
+
+void                    latexila_build_tools_save             (LatexilaBuildTools *build_tools);
+
+G_END_DECLS
+
+#endif /* __LATEXILA_BUILD_TOOLS_H__ */


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