## GtexSynctex

GtexSynctex — SyncTeX support between this application and Evince

## Functions

GtexSynctex * | gtex_synctex_get_instance ()
void | gtex_synctex_connect_evince_window ()
void | gtex_synctex_forward_search ()

## Signals

void | backward-search | Run Last

## Types and Values

struct | GtexSynctex

## Object Hierarchy

        GObject
        ╰── GtexSynctex

## Includes

    #include <gtex.h>

## Description

The GtexSynctex class (a singleton) implements the support of SyncTeX between this application and the Evince PDF viewer. It is used to switch between the source file(s) and the PDF, at the same position in the document. It is called the forward search: source file -> PDF. And backward search: PDF -> source file.

It works only with PDF files, it doesn't work with DVI or PS or other generated document formats.

D-Bus is used to communicate between this application and Evince. The implementation uses the asynchronous gdbus generated functions.

For the position, only the line is used, not the column. The column is a bit buggy.

## Functions

### gtex_synctex_get_instance ()

    GtexSynctex *
    gtex_synctex_get_instance (void);

#### Returns

the GtexSynctex singleton instance.

[transfer none]

### gtex_synctex_connect_evince_window ()

    void
    gtex_synctex_connect_evince_window (GtexSynctex *synctex,
                                        const gchar *pdf_uri);

Connects asynchronously the evince window for `pdf_uri` . This application will then listen the signals emitted by the evince window when the user wants to switch from the PDF to the corresponding *.tex file.

#### Parameters

synctex | the GtexSynctex instance. |
pdf_uri | the PDF URI. |

### gtex_synctex_forward_search ()

    void
    gtex_synctex_forward_search (GtexSynctex *synctex,
                                 GtkTextBuffer *buffer,
                                 GFile *buffer_location,
                                 GFile *main_tex_file,
                                 guint timestamp);

Does a forward search, i.e. switch from the *.tex file to the PDF file at the same position as the cursor position in `buffer` .

A correct `timestamp` of the event is important. If `GDK_CURRENT_TIME` is used instead, Evince is sometimes not shown directly, a notification appears instead saying that the "Document Viewer [...] is ready". It's more convenient if the Evince window is presented directly, which should work if the correct `timestamp` is provided.

#### Parameters

synctex | the GtexSynctex instance. |
buffer | a GtkTextBuffer. |
buffer_location | the *.tex file of `buffer` . |
main_tex_file | the main *.tex file of `buffer` . |
timestamp | the timestamp of the event. |

## Types and Values

### struct GtexSynctex

    struct GtexSynctex;

## Signal Details

### The `“backward-search”` signal

    void
    user_function (GtexSynctex *synctex,
                   char        *tex_uri,
                   int          line,
                   guint        timestamp,
                   gpointer     user_data)

The ::backward-search signal is emitted to perform a backward search, i.e. switching from the PDF to the source *.tex file.

#### Parameters

synctex | the GtexSynctex instance. |
tex_uri | the *.tex file URI. |
line | the line to jump to. |
timestamp | timestamp of the event. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last