[gnome-latex: 76/205] CMake: use FindLATEX module
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 76/205] CMake: use FindLATEX module
- Date: Fri, 14 Dec 2018 10:53:16 +0000 (UTC)
commit 0ae67e8286de487d796b892da71b1c8feed368dc
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sun Sep 20 18:20:17 2009 +0200
CMake: use FindLATEX module
CMakeLists.txt | 35 ++++++++++++++++++++++--
TODO | 2 +-
src/actions.c | 2 ++
src/callbacks.c | 18 ++++++++----
src/config.h.cmake | 5 ++++
src/main.h | 6 +++-
src/prefs.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++--------
7 files changed, 127 insertions(+), 21 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7673aa1..37e156c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,8 @@ SET(latexila_VERSION ${latexila_MAJOR}.${latexila_MINOR}.${latexila_PATCH})
MESSAGE(STATUS "*** Building LaTeXila ${latexila_VERSION} ***")
IF(NOT DATA_DIR)
- SET(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/latexila" CACHE PATH "The directory where the data is")
+ SET(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/latexila"
+ CACHE PATH "The directory where the data is")
ENDIF(NOT DATA_DIR)
OPTION(ENABLE_NLS "Native Language Support" ON)
@@ -37,9 +38,39 @@ FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK2 REQUIRED gtk+-2.0>=2.16 gtksourceview-2.0>=2.4)
SET(GTKSOURCEVIEW_VERSION ${GTK2_gtksourceview-2.0_VERSION})
+# commands
+
+SET(COMMAND_LATEX "latex")
+SET(COMMAND_PDFLATEX "pdflatex")
+SET(COMMAND_DVIPDF "dvipdf")
+SET(COMMAND_DVIPS "dvips")
+
+FIND_PACKAGE(LATEX)
+
+IF(LATEX_COMPILER)
+ SET(COMMAND_LATEX ${LATEX_COMPILER})
+ENDIF(LATEX_COMPILER)
+
+IF(PDFLATEX_COMPILER)
+ SET(COMMAND_PDFLATEX ${PDFLATEX_COMPILER})
+ENDIF(PDFLATEX_COMPILER)
+
+IF(DVIPDF_CONVERTER)
+ SET(COMMAND_DVIPDF ${DVIPDF_CONVERTER})
+ENDIF(DVIPDF_CONVERTER)
+
+IF(DVIPS_CONVERTER)
+ SET(COMMAND_DVIPS ${DVIPS_CONVERTER})
+ENDIF(DVIPS_CONVERTER)
+
+MESSAGE(STATUS "Commands: " ${COMMAND_LATEX} " ; " ${COMMAND_PDFLATEX} " ; "
+ ${COMMAND_DVIPDF} " ; " ${COMMAND_DVIPS})
+
+
INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS} ${latexila_BINARY_DIR}/src)
-CONFIGURE_FILE(${latexila_SOURCE_DIR}/src/config.h.cmake ${latexila_BINARY_DIR}/src/config.h)
+CONFIGURE_FILE(${latexila_SOURCE_DIR}/src/config.h.cmake
+ ${latexila_BINARY_DIR}/src/config.h)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(images)
diff --git a/TODO b/TODO
index 8ecc862..d7c94cb 100644
--- a/TODO
+++ b/TODO
@@ -16,7 +16,7 @@ Fri Sep 18, 2009 to Fri Sep 25, 2009
* text under or to the right of the icons?
[-] latex, pdflatex, dvips, dvipdf, ... commands
- - CMake: use FindLATEX module
+ x CMake: use FindLATEX module
- preferences
[-] command line option
diff --git a/src/actions.c b/src/actions.c
index 9c084f5..4ff2cc7 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -69,6 +69,8 @@ command_running_finished (void)
gchar *command_output_string = g_strdup ("");
gchar *tmp;
command_output_list = g_slist_reverse (command_output_list);
+
+ // TODO optimisation
guint nb_lines = g_slist_length (command_output_list);
for (gint i = 0 ; i < nb_lines ; i++)
{
diff --git a/src/callbacks.c b/src/callbacks.c
index 6966064..872b196 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -545,13 +545,15 @@ cb_latex (void)
gchar *title = _("Compile (latex)");
gchar *command[] = {
- "latex",
+ g_strdup (latexila.prefs->command_latex),
"-interaction=nonstopmode",
g_strdup (latexila.active_doc->path),
NULL
};
compile_document (title, command);
+
+ // TODO free command
}
void
@@ -562,13 +564,15 @@ cb_pdflatex (void)
gchar *title = _("Compile (pdflatex)");
gchar *command[] = {
- "pdflatex",
+ g_strdup (latexila.prefs->command_pdflatex),
"-interaction=nonstopmode",
g_strdup (latexila.active_doc->path),
NULL
};
compile_document (title, command);
+
+ // TODO free command
}
void
@@ -604,7 +608,7 @@ cb_dvi_to_pdf (void)
if (latexila.active_doc == NULL)
return;
- convert_document (_("DVI to PDF"), ".dvi", "dvipdf");
+ convert_document (_("DVI to PDF"), ".dvi", latexila.prefs->command_dvipdf);
}
void
@@ -613,7 +617,7 @@ cb_dvi_to_ps (void)
if (latexila.active_doc == NULL)
return;
- convert_document (_("DVI to PS"), ".dvi", "dvips");
+ convert_document (_("DVI to PS"), ".dvi", latexila.prefs->command_dvips);
}
void
@@ -1397,8 +1401,12 @@ create_preferences (void)
static void
free_latexila (void)
{
- g_free (latexila.prefs->command_view);
g_free (latexila.prefs->font_str);
+ g_free (latexila.prefs->command_view);
+ g_free (latexila.prefs->command_latex);
+ g_free (latexila.prefs->command_pdflatex);
+ g_free (latexila.prefs->command_dvipdf);
+ g_free (latexila.prefs->command_dvips);
g_free (latexila.prefs);
g_free (latexila.action_log);
diff --git a/src/config.h.cmake b/src/config.h.cmake
index e56d567..ef4c383 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -27,6 +27,11 @@
#cmakedefine LATEXILA_NLS_PACKAGE "@LATEXILA_NLS_PACKAGE@"
#cmakedefine LATEXILA_NLS_LOCALEDIR "@LATEXILA_NLS_LOCALEDIR@"
+#define COMMAND_LATEX "@COMMAND_LATEX@"
+#define COMMAND_PDFLATEX "@COMMAND_PDFLATEX@"
+#define COMMAND_DVIPDF "@COMMAND_DVIPDF@"
+#define COMMAND_DVIPS "@COMMAND_DVIPS@"
+
#define DATA_DIR "${DATA_DIR}"
#define GTKSOURCEVIEW_VERSION "@GTKSOURCEVIEW_VERSION@"
diff --git a/src/main.h b/src/main.h
index 6b919ff..31080e1 100644
--- a/src/main.h
+++ b/src/main.h
@@ -73,10 +73,14 @@ typedef struct
gint main_hpaned_pos;
gint vpaned_pos;
gint log_hpaned_pos;
- gchar *command_view;
gchar *font_str;
PangoFontDescription *font_desc;
gint font_size;
+ gchar *command_view;
+ gchar *command_latex;
+ gchar *command_pdflatex;
+ gchar *command_dvipdf;
+ gchar *command_dvips;
} preferences_t;
typedef struct
diff --git a/src/prefs.c b/src/prefs.c
index 5eb7e80..1d4ec11 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -42,8 +42,12 @@ static gboolean window_maximised_ = FALSE;
static gint main_hpaned_pos_ = 180;
static gint vpaned_pos_ = 380;
static gint log_hpaned_pos_ = 190;
-static gchar *command_view_ = "evince";
static gchar *font_ = "Monospace 10";
+static gchar *command_view_ = "evince";
+static gchar *command_latex_ = COMMAND_LATEX;
+static gchar *command_pdflatex_ = COMMAND_PDFLATEX;
+static gchar *command_dvipdf_ = COMMAND_DVIPDF;
+static gchar *command_dvips_ = COMMAND_DVIPS;
void
load_preferences (preferences_t *prefs)
@@ -164,8 +168,22 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
- // look, I see light, we are close to the exit!
-
+ gchar *font = g_key_file_get_string (key_file, PROGRAM_NAME, "font", &error);
+ if (error != NULL)
+ {
+ print_warning ("%s", error->message);
+ prefs->font_str = g_strdup (font_);
+ set_current_font_prefs (prefs);
+ g_error_free (error);
+ error = NULL;
+ }
+ else
+ {
+ prefs->font_str = g_strdup (font);
+ set_current_font_prefs (prefs);
+ g_free (font);
+ }
+
prefs->command_view = g_key_file_get_string (key_file, PROGRAM_NAME,
"command_view", &error);
if (error != NULL)
@@ -176,20 +194,46 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
- gchar *font = g_key_file_get_string (key_file, PROGRAM_NAME, "font", &error);
+ prefs->command_latex = g_key_file_get_string (key_file, PROGRAM_NAME,
+ "command_latex", &error);
if (error != NULL)
{
print_warning ("%s", error->message);
- prefs->font_str = g_strdup (font_);
- set_current_font_prefs (prefs);
+ prefs->command_latex = g_strdup (command_latex_);
g_error_free (error);
error = NULL;
}
- else
+
+ // look, I see light, we are close to the exit!
+
+ prefs->command_pdflatex = g_key_file_get_string (key_file, PROGRAM_NAME,
+ "command_pdflatex", &error);
+ if (error != NULL)
{
- prefs->font_str = g_strdup (font);
- set_current_font_prefs (prefs);
- g_free (font);
+ print_warning ("%s", error->message);
+ prefs->command_pdflatex = g_strdup (command_pdflatex_);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ prefs->command_dvipdf = g_key_file_get_string (key_file, PROGRAM_NAME,
+ "command_dvipdf", &error);
+ if (error != NULL)
+ {
+ print_warning ("%s", error->message);
+ prefs->command_dvipdf = g_strdup (command_dvipdf_);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ prefs->command_dvips = g_key_file_get_string (key_file, PROGRAM_NAME,
+ "command_dvips", &error);
+ if (error != NULL)
+ {
+ print_warning ("%s", error->message);
+ prefs->command_dvips = g_strdup (command_dvips_);
+ g_error_free (error);
+ error = NULL;
}
print_info ("load user preferences: OK");
@@ -208,9 +252,17 @@ save_preferences (preferences_t *prefs)
prefs->show_side_pane);
g_key_file_set_boolean (key_file, PROGRAM_NAME, "show_edit_toolbar",
prefs->show_edit_toolbar);
+ g_key_file_set_string (key_file, PROGRAM_NAME, "font", prefs->font_str);
g_key_file_set_string (key_file, PROGRAM_NAME, "command_view",
prefs->command_view);
- g_key_file_set_string (key_file, PROGRAM_NAME, "font", prefs->font_str);
+ g_key_file_set_string (key_file, PROGRAM_NAME, "command_latex",
+ prefs->command_latex);
+ g_key_file_set_string (key_file, PROGRAM_NAME, "command_pdflatex",
+ prefs->command_pdflatex);
+ g_key_file_set_string (key_file, PROGRAM_NAME, "command_dvipdf",
+ prefs->command_dvipdf);
+ g_key_file_set_string (key_file, PROGRAM_NAME, "command_dvips",
+ prefs->command_dvips);
/* set the keys that must be taken from the widgets */
GdkWindowState flag = gdk_window_get_state (gtk_widget_get_window (
@@ -292,8 +344,12 @@ load_default_preferences (preferences_t *prefs)
prefs->main_hpaned_pos = main_hpaned_pos_;
prefs->vpaned_pos = vpaned_pos_;
prefs->log_hpaned_pos = log_hpaned_pos_;
- prefs->command_view = g_strdup (command_view_);
prefs->font_str = g_strdup (font_);
+ prefs->command_view = g_strdup (command_view_);
+ prefs->command_latex = g_strdup (command_latex_);
+ prefs->command_pdflatex = g_strdup (command_pdflatex_);
+ prefs->command_dvipdf = g_strdup (command_dvipdf_);
+ prefs->command_dvips = g_strdup (command_dvips_);
set_current_font_prefs (prefs);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]