Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tectonic typesetter #188

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions data/ui/prefs.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,50 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="width-request">12</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes"> </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="typ_tectonic">
<property name="label" translatable="yes">Tectonic</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="focus-on-click">False</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">This program was not found on your system.</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">typ_pdflatex</property>
<signal name="toggled" handler="on_typ_tectonic_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox12">
<property name="visible">True</property>
Expand Down
2 changes: 2 additions & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ src/compile/latexmk.c
src/compile/latexmk.h
src/compile/rubber.c
src/compile/rubber.h
src/compile/tectonic.c
src/compile/tectonic.h
src/compile/texlive.c
src/compile/texlive.h
src/gui/gui-import.c
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gummi_SOURCES = biblio.c biblio.h \
compile/texlive.c compile/texlive.h \
compile/latexmk.c compile/latexmk.h \
compile/rubber.c compile/rubber.h \
compile/tectonic.c compile/tectonic.h \
gui/gui-menu.c gui/gui-menu.h \
gui/gui-tabmanager.c gui/gui-tabmanager.h \
gui/gui-import.c gui/gui-import.h \
Expand Down
83 changes: 83 additions & 0 deletions src/compile/tectonic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* @file tectonic.c
* @brief
*
* Copyright (C) 2009 Gummi Developers
* All Rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#include "tectonic.h"

#include "configfile.h"
#include "constants.h"
#include "external.h"
#include "utils.h"

gboolean tec_detected = FALSE;

void tectonic_init (void) {
if (external_exists (C_TECTONIC)) {
slog (L_INFO, "Typesetter detected: Tectonic %s\n",
external_version (C_TECTONIC));
tec_detected = TRUE;
}
}

gboolean tectonic_active (void) {
if (config_value_as_str_equals ("Compile", "typesetter", C_TECTONIC)) {
return TRUE;
}
return FALSE;
}

gboolean tectonic_detected (void) {
return tec_detected;
}

gchar* tectonic_get_command (const gchar* method, gchar* workfile) {
const gchar* outdir = g_strdup_printf ("--outdir \"%s\"", C_TMPDIR);
const gchar* flags = tectonic_get_flags (method);
gchar* teccmd;

teccmd = g_strdup_printf("tectonic %s %s \"%s\"", flags, outdir, workfile);

return teccmd;
}

gchar* tectonic_get_flags (const gchar *method) {
gchar *tecflags;
if (STR_EQU (method, "texpdf")) {
tecflags = g_strdup_printf("--outfmt pdf");
}
else {
// TODO: figure out if tectonic can output whatever the other formats are
tecflags = g_strdup_printf("");
}

if (config_get_boolean ("Compile", "synctex")) {
tecflags = g_strconcat ("--synctex ", tecflags, NULL);
}

return tecflags;
}
42 changes: 42 additions & 0 deletions src/compile/tectonic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @file tectonic.h
* @brief
*
* Copyright (C) 2009 Gummi Developers
* All Rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef __GUMMI_COMPILE_TECTONIC_H__
#define __GUMMI_COMPILE_TECTONIC_H__

#include <glib.h>

void tectonic_init (void);
gboolean tectonic_active (void);
gboolean tectonic_detected (void);

gchar* tectonic_get_command (const gchar* method, gchar* workfile);
gchar* tectonic_get_flags (const gchar *method);

#endif /* __GUMMI_COMPILE_TECTONIC_H */
1 change: 1 addition & 0 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
#define C_XELATEX "xelatex"
#define C_LUALATEX "lualatex"
#define C_RUBBER "rubber"
#define C_TECTONIC "tectonic"
#define C_LATEXMK "latexmk"

// Path definitions:
Expand Down
1 change: 1 addition & 0 deletions src/gui/gui-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "template.h"

#include "compile/rubber.h"
#include "compile/tectonic.h"
#include "compile/latexmk.h"
#include "compile/texlive.h"

Expand Down
19 changes: 19 additions & 0 deletions src/gui/gui-prefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "utils.h"

#include "compile/rubber.h"
#include "compile/tectonic.h"
#include "compile/latexmk.h"
#include "compile/texlive.h"

Expand Down Expand Up @@ -121,6 +122,8 @@ GuPrefsGui* prefsgui_init (GtkWindow* mainwindow) {
GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "typ_lualatex"));
p->typ_rubber =
GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "typ_rubber"));
p->typ_tectonic =
GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "typ_tectonic"));
p->typ_latexmk =
GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "typ_latexmk"));

Expand Down Expand Up @@ -306,6 +309,13 @@ static void set_tab_compilation_settings (GuPrefsGui* prefs) {
gtk_widget_set_tooltip_text (GTK_WIDGET(prefs->typ_rubber), "");
}

if (tectonic_detected()) {
if (tectonic_active())
gtk_toggle_button_set_active (prefs->typ_tectonic, TRUE);
gtk_widget_set_sensitive (GTK_WIDGET(prefs->typ_tectonic), TRUE);
gtk_widget_set_tooltip_text (GTK_WIDGET(prefs->typ_tectonic), "");
}

if (latexmk_detected()) {
if (latexmk_active())
gtk_toggle_button_set_active (prefs->typ_latexmk, TRUE);
Expand Down Expand Up @@ -717,6 +727,15 @@ void on_typ_rubber_toggled (GtkToggleButton* widget, void* user) {
}
}

G_MODULE_EXPORT
void on_typ_tectonic_toggled (GtkToggleButton* widget, void* user) {
if (gtk_toggle_button_get_active (widget)) {
config_set_string ("Compile", "typesetter", "tectonic");
typesetter_setup ();
}
}


G_MODULE_EXPORT
void on_typ_latexmk_toggled (GtkToggleButton* widget, void* user) {
if (gtk_toggle_button_get_active (widget)) {
Expand Down
1 change: 1 addition & 0 deletions src/gui/gui-prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct _GuPrefsGui {
GtkToggleButton* typ_xelatex;
GtkToggleButton* typ_lualatex;
GtkToggleButton* typ_rubber;
GtkToggleButton* typ_tectonic;
GtkToggleButton* typ_latexmk;

GtkToggleButton* method_texpdf;
Expand Down
5 changes: 5 additions & 0 deletions src/latex.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "utils.h"

#include "compile/rubber.h"
#include "compile/tectonic.h"
#include "compile/latexmk.h"
#include "compile/texlive.h"

Expand All @@ -59,6 +60,7 @@ GuLatex* latex_init (void) {

l->tex_version = texlive_init ();
rubber_init ();
tectonic_init ();
latexmk_init ();
return l;
}
Expand Down Expand Up @@ -92,6 +94,9 @@ gchar* latex_set_compile_cmd (GuEditor* ec) {
if (rubber_active()) {
texcmd = rubber_get_command (method, ec->workfile);
}
else if (tectonic_active()) {
texcmd = tectonic_get_command (method, ec->workfile);
}
else if (latexmk_active()) {
texcmd = latexmk_get_command (method, ec->workfile, ec->basename);
}
Expand Down