[latexila/wip/build-tools-revamp] BuildTool and BuildJob classes (not finished)
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/build-tools-revamp] BuildTool and BuildJob classes (not finished)
- Date: Thu, 1 May 2014 14:41:25 +0000 (UTC)
commit cdd6c286e3585558602eb4e434ed6427abd23e4a
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu May 1 15:14:56 2014 +0200
BuildTool and BuildJob classes (not finished)
docs/reference/latexila-sections.txt | 7 -
src/liblatexila/Makefile.am | 4 +
src/liblatexila/latexila-build-job.c | 101 ++++++++++
src/liblatexila/latexila-build-job.h | 68 +++++++
src/liblatexila/latexila-build-tool.c | 287 +++++++++++++++++++++++++++++
src/liblatexila/latexila-build-tool.h | 58 ++++++
src/liblatexila/latexila-build-tools.c | 177 +++---------------
src/liblatexila/latexila-build-tools.h | 63 -------
src/liblatexila/latexila-post-processor.c | 68 +++++++
src/liblatexila/latexila-post-processor.h | 31 +++-
src/liblatexila/latexila-types.h | 2 +
11 files changed, 639 insertions(+), 227 deletions(-)
---
diff --git a/docs/reference/latexila-sections.txt b/docs/reference/latexila-sections.txt
index 544000c..5e35b0c 100644
--- a/docs/reference/latexila-sections.txt
+++ b/docs/reference/latexila-sections.txt
@@ -4,13 +4,6 @@
<FILE>build-tools</FILE>
<TITLE>LatexilaBuildTools</TITLE>
LatexilaBuildTools
-LatexilaBuildTool
-LatexilaBuildJob
-LatexilaPostProcessorType
-latexila_build_tool_get_description
-latexila_build_tool_free
-latexila_get_post_processor_type_from_name
-latexila_get_post_processor_name_from_type
latexila_build_tools_load
latexila_build_tools_set_enabled
<SUBSECTION Standard>
diff --git a/src/liblatexila/Makefile.am b/src/liblatexila/Makefile.am
index 27a7ff2..6e18d46 100644
--- a/src/liblatexila/Makefile.am
+++ b/src/liblatexila/Makefile.am
@@ -3,6 +3,10 @@ AM_CPPFLAGS = $(WARN_CFLAGS)
noinst_LTLIBRARIES = liblatexila.la
liblatexila_la_SOURCES = \
+ latexila-build-job.c \
+ latexila-build-job.h \
+ latexila-build-tool.c \
+ latexila-build-tool.h \
latexila-build-tools.c \
latexila-build-tools.h \
latexila-build-tools-default.c \
diff --git a/src/liblatexila/latexila-build-job.c b/src/liblatexila/latexila-build-job.c
new file mode 100644
index 0000000..8c718ef
--- /dev/null
+++ b/src/liblatexila/latexila-build-job.c
@@ -0,0 +1,101 @@
+/*
+ * 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-build-job.h"
+
+struct _LatexilaBuildJobPrivate
+{
+ LatexilaPostProcessorType post_processor_type;
+ gchar *command;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (LatexilaBuildJob, latexila_build_job, G_TYPE_OBJECT)
+
+static void
+latexila_build_job_dispose (GObject *object)
+{
+
+ G_OBJECT_CLASS (latexila_build_job_parent_class)->dispose (object);
+}
+
+static void
+latexila_build_job_finalize (GObject *object)
+{
+ LatexilaBuildJob *build_job = LATEXILA_BUILD_JOB (object);
+
+ g_free (build_job->priv->command);
+
+ G_OBJECT_CLASS (latexila_build_job_parent_class)->finalize (object);
+}
+
+static void
+latexila_build_job_class_init (LatexilaBuildJobClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = latexila_build_job_dispose;
+ object_class->finalize = latexila_build_job_finalize;
+}
+
+static void
+latexila_build_job_init (LatexilaBuildJob *self)
+{
+ self->priv = latexila_build_job_get_instance_private (self);
+}
+
+LatexilaBuildJob *
+latexila_build_job_new (void)
+{
+ return g_object_new (LATEXILA_TYPE_BUILD_JOB, NULL);
+}
+
+const gchar *
+latexila_build_job_get_command (LatexilaBuildJob *build_job)
+{
+ g_return_val_if_fail (LATEXILA_IS_BUILD_JOB (build_job), NULL);
+
+ return build_job->priv->command;
+}
+
+void
+latexila_build_job_set_command (LatexilaBuildJob *build_job,
+ const gchar *command)
+{
+ g_return_if_fail (LATEXILA_IS_BUILD_JOB (build_job));
+
+ g_free (build_job->priv->command);
+ build_job->priv->command = g_strdup (command);
+}
+
+LatexilaPostProcessorType
+latexila_build_job_get_post_processor_type (LatexilaBuildJob *build_job)
+{
+ g_return_val_if_fail (LATEXILA_IS_BUILD_JOB (build_job), LATEXILA_POST_PROCESSOR_TYPE_ALL_OUTPUT);
+
+ return build_job->priv->post_processor_type;
+}
+
+void
+latexila_build_job_set_post_processor_type (LatexilaBuildJob *build_job,
+ LatexilaPostProcessorType post_processor_type)
+{
+ g_return_if_fail (LATEXILA_IS_BUILD_JOB (build_job));
+
+ build_job->priv->post_processor_type = post_processor_type;
+}
diff --git a/src/liblatexila/latexila-build-job.h b/src/liblatexila/latexila-build-job.h
new file mode 100644
index 0000000..41db320
--- /dev/null
+++ b/src/liblatexila/latexila-build-job.h
@@ -0,0 +1,68 @@
+/*
+ * 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_JOB_H__
+#define __LATEXILA_BUILD_JOB_H__
+
+#include <glib-object.h>
+#include "latexila-types.h"
+#include "latexila-post-processor.h"
+
+G_BEGIN_DECLS
+
+#define LATEXILA_TYPE_BUILD_JOB (latexila_build_job_get_type ())
+#define LATEXILA_BUILD_JOB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LATEXILA_TYPE_BUILD_JOB,
LatexilaBuildJob))
+#define LATEXILA_BUILD_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LATEXILA_TYPE_BUILD_JOB,
LatexilaBuildJobClass))
+#define LATEXILA_IS_BUILD_JOB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LATEXILA_TYPE_BUILD_JOB))
+#define LATEXILA_IS_BUILD_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LATEXILA_TYPE_BUILD_JOB))
+#define LATEXILA_BUILD_JOB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LATEXILA_TYPE_BUILD_JOB,
LatexilaBuildJobClass))
+
+typedef struct _LatexilaBuildJobClass LatexilaBuildJobClass;
+typedef struct _LatexilaBuildJobPrivate LatexilaBuildJobPrivate;
+
+struct _LatexilaBuildJob
+{
+ GObject parent;
+
+ LatexilaBuildJobPrivate *priv;
+};
+
+struct _LatexilaBuildJobClass
+{
+ GObjectClass parent_class;
+};
+
+GType latexila_build_job_get_type (void) G_GNUC_CONST;
+
+LatexilaBuildJob * latexila_build_job_new (void);
+
+const gchar * latexila_build_job_get_command (LatexilaBuildJob *build_job);
+
+void latexila_build_job_set_command (LatexilaBuildJob *build_job,
+ const gchar *command);
+
+LatexilaPostProcessorType
+ latexila_build_job_get_post_processor_type (LatexilaBuildJob *build_job);
+
+void latexila_build_job_set_post_processor_type (LatexilaBuildJob *build_job,
+ LatexilaPostProcessorType
post_processor_type);
+
+G_END_DECLS
+
+#endif /* __LATEXILA_BUILD_JOB_H__ */
diff --git a/src/liblatexila/latexila-build-tool.c b/src/liblatexila/latexila-build-tool.c
new file mode 100644
index 0000000..18f73ed
--- /dev/null
+++ b/src/liblatexila/latexila-build-tool.c
@@ -0,0 +1,287 @@
+/*
+ * 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-build-tool.h"
+
+struct _LatexilaBuildToolPrivate
+{
+ gchar *label;
+ gchar *description;
+ gchar *extensions;
+ gchar *icon;
+ gchar *files_to_open;
+ gint id;
+
+ /* A list of LatexilaBuildJob's. */
+ GSList *jobs;
+
+ guint enabled : 1;
+};
+
+enum
+{
+ PROP_0,
+ PROP_LABEL,
+ PROP_DESCRIPTION,
+ PROP_EXTENSIONS,
+ PROP_ICON,
+ PROP_FILES_TO_OPEN,
+ PROP_ID,
+ PROP_ENABLED
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (LatexilaBuildTool, latexila_build_tool, G_TYPE_OBJECT)
+
+static void
+latexila_build_tool_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ LatexilaBuildTool *build_tool = LATEXILA_BUILD_TOOL (object);
+
+ switch (prop_id)
+ {
+ case PROP_LABEL:
+ g_value_set_string (value, build_tool->priv->label);
+ break;
+
+ case PROP_DESCRIPTION:
+ g_value_set_string (value, build_tool->priv->description);
+ break;
+
+ case PROP_EXTENSIONS:
+ g_value_set_string (value, build_tool->priv->extensions);
+ break;
+
+ case PROP_ICON:
+ g_value_set_string (value, build_tool->priv->icon);
+ break;
+
+ case PROP_FILES_TO_OPEN:
+ g_value_set_string (value, build_tool->priv->files_to_open);
+ break;
+
+ case PROP_ID:
+ g_value_set_int (value, build_tool->priv->id);
+ break;
+
+ case PROP_ENABLED:
+ g_value_set_boolean (value, build_tool->priv->enabled);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+latexila_build_tool_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ LatexilaBuildTool *build_tool = LATEXILA_BUILD_TOOL (object);
+
+ switch (prop_id)
+ {
+ case PROP_LABEL:
+ g_free (build_tool->priv->label);
+ build_tool->priv->label = g_value_dup_string (value);
+ break;
+
+ case PROP_DESCRIPTION:
+ g_free (build_tool->priv->description);
+ build_tool->priv->description = g_value_dup_string (value);
+ break;
+
+ case PROP_EXTENSIONS:
+ g_free (build_tool->priv->extensions);
+ build_tool->priv->extensions = g_value_dup_string (value);
+ break;
+
+ case PROP_ICON:
+ g_free (build_tool->priv->icon);
+ build_tool->priv->icon = g_value_dup_string (value);
+ break;
+
+ case PROP_FILES_TO_OPEN:
+ g_free (build_tool->priv->files_to_open);
+ build_tool->priv->files_to_open = g_value_dup_string (value);
+ break;
+
+ case PROP_ID:
+ build_tool->priv->id = g_value_get_int (value);
+ break;
+
+ case PROP_ENABLED:
+ build_tool->priv->enabled = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+latexila_build_tool_dispose (GObject *object)
+{
+ LatexilaBuildTool *build_tool = LATEXILA_BUILD_TOOL (object);
+
+ /* TODO free jobs */
+
+ G_OBJECT_CLASS (latexila_build_tool_parent_class)->dispose (object);
+}
+
+static void
+latexila_build_tool_finalize (GObject *object)
+{
+ LatexilaBuildTool *build_tool = LATEXILA_BUILD_TOOL (object);
+
+ g_free (build_tool->priv->label);
+ g_free (build_tool->priv->description);
+ g_free (build_tool->priv->extensions);
+ g_free (build_tool->priv->icon);
+ g_free (build_tool->priv->files_to_open);
+
+ G_OBJECT_CLASS (latexila_build_tool_parent_class)->finalize (object);
+}
+
+static void
+latexila_build_tool_class_init (LatexilaBuildToolClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = latexila_build_tool_get_property;
+ object_class->set_property = latexila_build_tool_set_property;
+ object_class->dispose = latexila_build_tool_dispose;
+ object_class->finalize = latexila_build_tool_finalize;
+
+ g_object_class_install_property (object_class,
+ PROP_LABEL,
+ g_param_spec_string ("label",
+ "Label",
+ "",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_DESCRIPTION,
+ g_param_spec_string ("description",
+ "Description",
+ "",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_EXTENSIONS,
+ g_param_spec_string ("extensions",
+ "Extensions",
+ "",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_ICON,
+ g_param_spec_string ("icon",
+ "Icon",
+ "",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_FILES_TO_OPEN,
+ g_param_spec_string ("files-to-open",
+ "Files to open",
+ "",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * LatexilaBuildTool:id:
+ *
+ * The build tool ID. It is used only by the default build tools, for saving
+ * in #GSettings the lists of enabled/disabled build tools.
+ */
+ g_object_class_install_property (object_class,
+ PROP_ID,
+ g_param_spec_int ("id",
+ "ID",
+ "",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_ENABLED,
+ g_param_spec_boolean ("enabled",
+ "Enabled",
+ "",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+latexila_build_tool_init (LatexilaBuildTool *self)
+{
+ self->priv = latexila_build_tool_get_instance_private (self);
+}
+
+LatexilaBuildTool *
+latexila_build_tool_new (void)
+{
+ return g_object_new (LATEXILA_TYPE_BUILD_TOOL, NULL);
+}
+
+/**
+ * latexila_build_tool_get_description:
+ * @build_tool: a #LatexilaBuildTool.
+ *
+ * Gets the description. The label is returned if the description is empty.
+ *
+ * Returns: the description.
+ */
+const gchar *
+latexila_build_tool_get_description (LatexilaBuildTool *build_tool)
+{
+ if (build_tool->priv->description == NULL ||
+ build_tool->priv->description[0] == '\0')
+ {
+ return build_tool->priv->label;
+ }
+
+ return build_tool->priv->description;
+}
diff --git a/src/liblatexila/latexila-build-tool.h b/src/liblatexila/latexila-build-tool.h
new file mode 100644
index 0000000..b5b329c
--- /dev/null
+++ b/src/liblatexila/latexila-build-tool.h
@@ -0,0 +1,58 @@
+/*
+ * 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_TOOL_H__
+#define __LATEXILA_BUILD_TOOL_H__
+
+#include "latexila-types.h"
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define LATEXILA_TYPE_BUILD_TOOL (latexila_build_tool_get_type ())
+#define LATEXILA_BUILD_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LATEXILA_TYPE_BUILD_TOOL,
LatexilaBuildTool))
+#define LATEXILA_BUILD_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LATEXILA_TYPE_BUILD_TOOL,
LatexilaBuildToolClass))
+#define LATEXILA_IS_BUILD_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LATEXILA_TYPE_BUILD_TOOL))
+#define LATEXILA_IS_BUILD_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LATEXILA_TYPE_BUILD_TOOL))
+#define LATEXILA_BUILD_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LATEXILA_TYPE_BUILD_TOOL,
LatexilaBuildToolClass))
+
+typedef struct _LatexilaBuildToolClass LatexilaBuildToolClass;
+typedef struct _LatexilaBuildToolPrivate LatexilaBuildToolPrivate;
+
+struct _LatexilaBuildTool
+{
+ GObject parent;
+
+ LatexilaBuildToolPrivate *priv;
+};
+
+struct _LatexilaBuildToolClass
+{
+ GObjectClass parent_class;
+};
+
+GType latexila_build_tool_get_type (void) G_GNUC_CONST;
+
+LatexilaBuildTool * latexila_build_tool_new (void);
+
+const gchar * latexila_build_tool_get_description (LatexilaBuildTool *build_tool);
+
+G_END_DECLS
+
+#endif /* __LATEXILA_BUILD_TOOL_H__ */
diff --git a/src/liblatexila/latexila-build-tools.c b/src/liblatexila/latexila-build-tools.c
index 04e634a..3afcca4 100644
--- a/src/liblatexila/latexila-build-tools.c
+++ b/src/liblatexila/latexila-build-tools.c
@@ -35,6 +35,9 @@
#include "latexila-build-tools.h"
#include <glib/gi18n.h>
#include "latexila-build-tools-default.h"
+#include "latexila-build-tool.h"
+#include "latexila-build-job.h"
+#include "latexila-post-processor.h"
struct _LatexilaBuildToolsPrivate
{
@@ -54,147 +57,18 @@ G_DEFINE_TYPE_WITH_PRIVATE (LatexilaBuildTools, latexila_build_tools, G_TYPE_OBJ
static guint signals[LAST_SIGNAL];
-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);
-}
-
-/**
- * latexila_build_tool_free:
- * @build_tool: the build tool to free.
- */
-void
-latexila_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);
- }
-}
-
-/**
- * latexila_build_tool_get_description:
- * @build_tool: a #LatexilaBuildTool.
- *
- * Gets the description. The label is returned if the description is empty.
- *
- * Returns: the description.
- */
-const gchar *
-latexila_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;
-}
-
-/**
- * latexila_get_post_processor_type_from_name:
- * @name: the name of the post-processor.
- * @type: the output post-processor type.
- *
- * Returns: %TRUE on success, %FALSE otherwise.
- */
-gboolean
-latexila_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;
-}
-
-/**
- * latexila_get_post_processor_name_from_type:
- * @type: the post-processor type.
- *
- * Returns: the post-processor name.
- */
-const gchar *
-latexila_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_finalize (GObject *object)
+latexila_build_tools_dispose (GObject *object)
{
LatexilaBuildTools *build_tools = LATEXILA_BUILD_TOOLS (object);
- g_list_free_full (build_tools->build_tools, (GDestroyNotify) latexila_build_tool_free);
- latexila_build_tool_free (build_tools->priv->cur_tool);
- build_job_free (build_tools->priv->cur_job);
+ g_list_free_full (build_tools->build_tools, g_object_unref);
+ build_tools->build_tools = NULL;
+
+ g_clear_object (&build_tools->priv->cur_tool);
+ g_clear_object (&build_tools->priv->cur_job);
- G_OBJECT_CLASS (latexila_build_tools_parent_class)->finalize (object);
+ G_OBJECT_CLASS (latexila_build_tools_parent_class)->dispose (object);
}
static void
@@ -202,7 +76,7 @@ latexila_build_tools_class_init (LatexilaBuildToolsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = latexila_build_tools_finalize;
+ object_class->dispose = latexila_build_tools_dispose;
/**
* LatexilaBuildTools::loaded:
@@ -257,29 +131,31 @@ parser_start_element (GMarkupParseContext *context,
LatexilaBuildTool *cur_tool;
gint i;
- latexila_build_tool_free (build_tools->priv->cur_tool);
- cur_tool = build_tool_new ();
+ g_clear_object (&build_tools->priv->cur_tool);
+ cur_tool = latexila_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);
+ gint id = g_strtod (attribute_values[i], NULL);
+ g_object_set (cur_tool, "id", id, 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");
+ gboolean enabled = g_str_equal (attribute_values[i], "true");
+ g_object_set (cur_tool, "enabled", enabled, NULL);
}
else if (g_str_equal (attribute_names[i], "extensions"))
{
- cur_tool->extensions = g_strdup (attribute_values[i]);
+ g_object_set (cur_tool, "extensions", attribute_values[i], NULL);
}
else if (g_str_equal (attribute_names[i], "icon"))
{
- cur_tool->icon = g_strdup (attribute_values[i]);
+ g_object_set (cur_tool, "icon", attribute_values[i], NULL);
}
else if (error != NULL)
{
@@ -296,8 +172,8 @@ parser_start_element (GMarkupParseContext *context,
LatexilaBuildJob *cur_job;
gint i;
- build_job_free (build_tools->priv->cur_job);
- cur_job = build_job_new ();
+ g_clear_object (&build_tools->priv->cur_job);
+ cur_job = latexila_build_job_new ();
build_tools->priv->cur_job = cur_job;
for (i = 0; attribute_names[i] != NULL; i++)
@@ -306,9 +182,9 @@ parser_start_element (GMarkupParseContext *context,
{
LatexilaPostProcessorType type;
- if (latexila_get_post_processor_type_from_name (attribute_values[i], &type))
+ if (latexila_post_processor_get_type_from_name (attribute_values[i], &type))
{
- cur_job->post_processor_type = type;
+ latexila_build_job_set_post_processor_type (cur_job, type);
}
else if (error != NULL)
{
@@ -568,9 +444,6 @@ latexila_build_tools_set_enabled (LatexilaBuildTools *build_tools,
g_return_if_fail (build_tool != NULL);
- if (build_tool->enabled != enabled)
- {
- build_tool->enabled = enabled;
- g_signal_emit (build_tools, signals[SIGNAL_MODIFIED], 0);
- }
+ g_object_set (build_tool, "enabled", enabled, NULL);
+ g_signal_emit (build_tools, signals[SIGNAL_MODIFIED], 0);
}
diff --git a/src/liblatexila/latexila-build-tools.h b/src/liblatexila/latexila-build-tools.h
index e097e20..0a9c7be 100644
--- a/src/liblatexila/latexila-build-tools.h
+++ b/src/liblatexila/latexila-build-tools.h
@@ -34,8 +34,6 @@ G_BEGIN_DECLS
typedef struct _LatexilaBuildToolsClass LatexilaBuildToolsClass;
typedef struct _LatexilaBuildToolsPrivate LatexilaBuildToolsPrivate;
-typedef struct _LatexilaBuildJob LatexilaBuildJob;
-typedef struct _LatexilaBuildTool LatexilaBuildTool;
/**
* LatexilaBuildTools:
@@ -59,69 +57,8 @@ struct _LatexilaBuildToolsClass
GObjectClass parent_class;
};
-/**
- * LatexilaPostProcessorType:
- * @LATEXILA_POST_PROCESSOR_TYPE_NO_OUTPUT: no output.
- * @LATEXILA_POST_PROCESSOR_TYPE_ALL_OUTPUT: all output.
- * @LATEXILA_POST_PROCESSOR_TYPE_LATEX: for a LaTeX command.
- * @LATEXILA_POST_PROCESSOR_TYPE_LATEXMK: for the latexmk command.
- *
- * Types of post-processors.
- */
-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;
-
-/**
- * LatexilaBuildJob:
- * @post_processor_type: the post-processor type.
- * @command: the command to run.
- */
-struct _LatexilaBuildJob
-{
- LatexilaPostProcessorType post_processor_type;
- gchar *command;
-};
-
-/**
- * LatexilaBuildTool:
- * @label: the label.
- * @description: the description.
- * @extensions: the extensions.
- * @icon: the icon.
- * @files_to_open: the files to open.
- * @jobs: a list of #LatexilaBuildJob's.
- * @id: ID of the build tool. It is used only by the default build tools, for
- * saving in #GSettings the lists of enabled/disabled build tools.
- * @enabled: whether the build tool is enabled (for showing it in the UI).
- */
-struct _LatexilaBuildTool
-{
- gchar *label;
- gchar *description;
- gchar *extensions;
- gchar *icon;
- gchar *files_to_open;
- GSList *jobs;
- gint id;
- guint enabled : 1;
-};
-
GType latexila_build_tools_get_type (void) G_GNUC_CONST;
-void latexila_build_tool_free (LatexilaBuildTool *build_tool);
-
-const gchar * latexila_build_tool_get_description (LatexilaBuildTool *build_tool);
-
-gboolean latexila_get_post_processor_type_from_name (const gchar *name,
- LatexilaPostProcessorType *type);
-
-const gchar * latexila_get_post_processor_name_from_type (LatexilaPostProcessorType type);
-
void latexila_build_tools_load (LatexilaBuildTools *build_tools,
GFile *xml_file);
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index f5861db..19e2b40 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -34,6 +34,74 @@ enum
G_DEFINE_TYPE_WITH_PRIVATE (LatexilaPostProcessor, latexila_post_processor, G_TYPE_OBJECT)
+/**
+ * latexila_post_processor_get_type_from_name:
+ * @name: the name of the post-processor.
+ * @type: (out): the output post-processor type.
+ *
+ * Returns: %TRUE on success, %FALSE otherwise.
+ */
+gboolean
+latexila_post_processor_get_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;
+}
+
+/**
+ * latexila_post_processor_get_name_from_type:
+ * @type: the post-processor type.
+ *
+ * Returns: the post-processor name.
+ */
+const gchar *
+latexila_post_processor_get_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_post_processor_get_property (GObject *object,
guint prop_id,
diff --git a/src/liblatexila/latexila-post-processor.h b/src/liblatexila/latexila-post-processor.h
index b889d38..61049a1 100644
--- a/src/liblatexila/latexila-post-processor.h
+++ b/src/liblatexila/latexila-post-processor.h
@@ -36,6 +36,22 @@ G_BEGIN_DECLS
typedef struct _LatexilaPostProcessorClass LatexilaPostProcessorClass;
typedef struct _LatexilaPostProcessorPrivate LatexilaPostProcessorPrivate;
+/**
+ * LatexilaPostProcessorType:
+ * @LATEXILA_POST_PROCESSOR_TYPE_NO_OUTPUT: no output.
+ * @LATEXILA_POST_PROCESSOR_TYPE_ALL_OUTPUT: all output.
+ * @LATEXILA_POST_PROCESSOR_TYPE_LATEX: for a LaTeX command.
+ * @LATEXILA_POST_PROCESSOR_TYPE_LATEXMK: for the latexmk command.
+ *
+ * Types of post-processors.
+ */
+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;
struct _LatexilaPostProcessor
{
@@ -54,14 +70,19 @@ 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;
+
+gboolean latexila_post_processor_get_type_from_name (const gchar *name,
+ LatexilaPostProcessorType *type);
+
+const gchar * latexila_post_processor_get_name_from_type (LatexilaPostProcessorType type);
-LatexilaPostProcessor * latexila_post_processor_new (void);
+LatexilaPostProcessor * latexila_post_processor_new (void);
-void latexila_post_processor_process (LatexilaPostProcessor *post_processor,
- const gchar *output);
+void latexila_post_processor_process (LatexilaPostProcessor *post_processor,
+ const gchar *output);
-GSList * latexila_post_processor_get_messages (LatexilaPostProcessor *post_processor);
+GSList * latexila_post_processor_get_messages (LatexilaPostProcessor
*post_processor);
G_END_DECLS
diff --git a/src/liblatexila/latexila-types.h b/src/liblatexila/latexila-types.h
index 64f5523..dce5031 100644
--- a/src/liblatexila/latexila-types.h
+++ b/src/liblatexila/latexila-types.h
@@ -24,6 +24,8 @@
G_BEGIN_DECLS
+typedef struct _LatexilaBuildJob LatexilaBuildJob;
+typedef struct _LatexilaBuildTool LatexilaBuildTool;
typedef struct _LatexilaBuildTools LatexilaBuildTools;
typedef struct _LatexilaBuildToolsDefault LatexilaBuildToolsDefault;
typedef struct _LatexilaBuildToolsPersonal LatexilaBuildToolsPersonal;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]