GtexPostProcessor

GtexPostProcessor — post-processor base class

Functions

Properties

gboolean has-details Read / Write / Construct

Types and Values

Object Hierarchy

    GObject
    ╰── GtexPostProcessor
        ├── GtexPostProcessorAllOutput
        ├── GtexPostProcessorLatex
        ╰── GtexPostProcessorLatexmk

Includes

#include <gtex.h>

Description

When running a build tool, a post-processor is used to filter the output to display only the relevant messages. The output can come from the stdout/stderr of a build job command, or the contents of a log file, etc. In this application only the former is currently used, but it would be more robust to read the LaTeX log file.

For the no-output post-processor type, you should not need to create a GtexPostProcessor object, since the result is empty.

The implementations sometimes assume that a post-processor can be used at most one time.

Functions

gtex_post_processor_get_name_from_type ()

const gchar *
gtex_post_processor_get_name_from_type
                               (GtexPostProcessorType type);

Parameters

type

the post-processor type.

 

Returns

the post-processor name.


gtex_post_processor_get_type_from_name ()

gboolean
gtex_post_processor_get_type_from_name
                               (const gchar *name,
                                GtexPostProcessorType *type);

Parameters

name

the name of the post-processor.

 

type

the output post-processor type.

[out]

Returns

TRUE on success, FALSE otherwise.


gtex_post_processor_process_async ()

void
gtex_post_processor_process_async (GtexPostProcessor *pp,
                                   GFile *file,
                                   GInputStream *stream,
                                   GCancellable *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data);

Asynchronously process an input stream. The input stream can for example come from the output of a command launched with GSubprocess, or it can be the input stream of a file (e.g. the LaTeX log file), etc.

callback will be called when the operation is finished. You can then call gtex_post_processor_process_finish().

Parameters

pp

a post-processor.

 

file

the GFile on which the build tool is run.

 

stream

the input stream to process.

 

cancellable

a GCancellable.

 

callback

the callback to call when the operation is finished.

 

user_data

the data to pass to the callback.

 

gtex_post_processor_process_finish ()

void
gtex_post_processor_process_finish (GtexPostProcessor *pp,
                                    GAsyncResult *result,
                                    gboolean succeeded);

Finishes an operation started with gtex_post_processor_process_async(). After calling this function, you can get the filtered messages with gtex_post_processor_get_messages().

Parameters

pp

a post-processor.

 

result

a GAsyncResult.

 

succeeded

whether the subprocess has succeeded.

 

gtex_post_processor_start ()

void
gtex_post_processor_start (GtexPostProcessor *pp,
                           GFile *file);

Manually starts the post-processor.

Not needed if you use gtex_post_processor_process_async().

Parameters

pp

a GtexPostProcessor.

 

file

the GFile on which the build tool is run.

 

gtex_post_processor_process_line ()

void
gtex_post_processor_process_line (GtexPostProcessor *pp,
                                  gchar *line);

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 gtex_post_processor_process_async().

Parameters

pp

a GtexPostProcessor.

 

line

a line, without the newline character(s).

[transfer full]

gtex_post_processor_end ()

void
gtex_post_processor_end (GtexPostProcessor *pp,
                         gboolean succeeded);

Manually ends the processing.

Not needed if you use gtex_post_processor_process_async().

Parameters

pp

a GtexPostProcessor.

 

succeeded

whether the subprocess has succeeded.

 

gtex_post_processor_get_messages ()

const GList *
gtex_post_processor_get_messages (GtexPostProcessor *pp,
                                  gboolean show_details);

Gets the filtered messages. Call this function only after calling gtex_post_processor_process_finish() or gtex_post_processor_end().

Another solution would have been to pass the GtexBuildView to the post-processor, so the filtered messages can directly be outputed to the build view as they come. But some post-processors don't know what to output directly. The latexmk post-processor can have a simplified output with only the LaTeX messages, in which case the detailed messages are also available, but this can be known only when all the stream has been processed.

Obviously if the build view is passed to the post-processor, the latexmk post-processor can output its messages only at the end. But another reason to not pass the build view is for the unit tests. It is easier for the unit tests to check the returned GList than analyzing a GtkTreeView. Of course it would be possible to keep also the messages in a GList and have this function only for the unit tests, but it takes more memory (unless a custom GtkTreeModel is implemented), or another function is needed to configure whether a GList is kept in memory or not... It becomes a little too complicated, and doesn't really worth the effort as most users use latexmk.

The current solution is "good enough". And "good enough" is... "good enough".

Parameters

pp

a post-processor.

 

show_details

whether to show the details. Has no effect if “has-details” is FALSE.

 

Returns

the tree of filtered messages.

[transfer none][element-type GtexBuildMsg]


gtex_post_processor_take_messages ()

GQueue *
gtex_post_processor_take_messages (GtexPostProcessor *pp);

Takes ownership of all the messages. Since GQueue is not reference counted, pp is emptied and is thus useless after calling this function.

[skip]

Parameters

Returns

the tree of filtered messages, or NULL. Element types: GtexBuildMsg.

[transfer full][nullable]

Types and Values

GtexPostProcessor

typedef struct _GtexPostProcessor GtexPostProcessor;

enum GtexPostProcessorType

Types of post-processors.

Members

GTEX_POST_PROCESSOR_TYPE_NO_OUTPUT

no output.

 

GTEX_POST_PROCESSOR_TYPE_ALL_OUTPUT

all output.

 

GTEX_POST_PROCESSOR_TYPE_LATEX

for a LaTeX command.

 

GTEX_POST_PROCESSOR_TYPE_LATEXMK

for the latexmk command.

 

GTEX_POST_PROCESSOR_TYPE_NB_TYPES

number of post-processor types.

 

Property Details

The “has-details” property

  “has-details”              gboolean

Owner: GtexPostProcessor

Flags: Read / Write / Construct

Default value: FALSE