1 /**
2 * @file rubber.c
3 * @brief
4 *
5 * Copyright (C) 2009 Gummi Developers
6 * All Rights reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person
9 * obtaining a copy of this software and associated documentation
10 * files (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use,
12 * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following
15 * conditions:
16 *
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30 #include "rubber.h"
31
32 #include "configfile.h"
33 #include "constants.h"
34 #include "external.h"
35 #include "utils.h"
36
37 gboolean rub_detected = FALSE;
38
rubber_init(void)39 void rubber_init (void) {
40
41 if (external_exists (C_RUBBER)) {
42 // TODO: check if supported version
43 slog (L_INFO, "Typesetter detected: Rubber %s\n",
44 external_version (C_RUBBER));
45 rub_detected = TRUE;
46 }
47 }
48
rubber_active(void)49 gboolean rubber_active (void) {
50 if (config_value_as_str_equals ("Compile", "typesetter", C_RUBBER)) {
51 return TRUE;
52 }
53 return FALSE;
54 }
55
rubber_detected(void)56 gboolean rubber_detected (void) {
57 return rub_detected;
58 }
59
rubber_get_command(const gchar * method,gchar * workfile)60 gchar* rubber_get_command (const gchar* method, gchar* workfile) {
61
62 const gchar* outdir = g_strdup_printf ("--into=\"%s\"", C_TMPDIR);
63 const gchar* flags = rubber_get_flags (method);
64 gchar* rubcmd;
65
66 rubcmd = g_strdup_printf("rubber %s %s \"%s\"", flags, outdir, workfile);
67
68 return rubcmd;
69 }
70
rubber_get_flags(const gchar * method)71 gchar* rubber_get_flags (const gchar *method) {
72 gchar *rubflags;
73 if (STR_EQU (method, "texpdf")) {
74 rubflags = g_strdup_printf("-d -q");
75 }
76 else {
77 rubflags = g_strdup_printf("-p -d -q");
78 }
79
80 if (config_get_boolean ("Compile", "synctex")) {
81 rubflags = g_strconcat ("--synctex ", rubflags, NULL);
82 }
83
84 return rubflags;
85 }
86