[gnome-latex: 125/205] Clean-up auxiliaries files after close
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 125/205] Clean-up auxiliaries files after close
- Date: Fri, 14 Dec 2018 10:57:23 +0000 (UTC)
commit 6d0df16d25c2daf0e8f4b67f4aa932654f9ab914
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Thu Nov 19 19:35:46 2009 +0100
Clean-up auxiliaries files after close
The files that are deleted are:
.aux .bit .blg .bbl .lof .log .lot .glo .glx .gxg .gxs .idx .ilg .ind
.out .url .svn .toc (thanks again Kile ;)
There is an option in the preferences, with a tooltip.
TODO | 20 +-------------------
src/callbacks.c | 29 +++++++++++++++++++++++++++++
src/external_commands.c | 3 +++
src/main.h | 1 +
src/prefs.c | 31 +++++++++++++++++++++++++++++++
5 files changed, 65 insertions(+), 19 deletions(-)
---
diff --git a/TODO b/TODO
index b68d2b6..ba5f12e 100644
--- a/TODO
+++ b/TODO
@@ -1,15 +1,6 @@
TODO LaTeXila
-[x] File browser in the side bar
- x tabs to switch between "Symbols" and "File Browser"
- x file browser integrated
- x sort the files in alphabetical order
- x save the current folder in the prefs
- x add a link to the home user directory
- x other pixbuf for *.pdf, *.dvi and *.ps files
- x if clicking on a *.pdf, *.dvi or *.ps file, show the document (add a new action)
- x add an option in the preferences: show only *.tex, *.pdf, *.dvi, *.ps and *.bib files
- x add a button to jump to the directory of the current document
+[x] clean-up auxiliaries files after close (*.aux, *.log, *.out, *.toc, ...)
[-] Templates
- create a few default templates
@@ -19,12 +10,6 @@ TODO LaTeXila
[-] BibTeX support
-[-] delete auxiliaries files on exit (*.aux, *.log, *.out, *.toc, ...)
-
-[x] remember the files opened at exit and reopen them on startup
- x do the main work
- x add an option in the preferences
-
[-] Documents menu
- close all
- save all
@@ -32,6 +17,3 @@ TODO LaTeXila
[-] undo/redo and the "saved" document property
- detect when the buffer is the same as in the file currently saved
-
-[x] open document
- x verify if the document is not already opened
diff --git a/src/callbacks.c b/src/callbacks.c
index ce19de7..d292c09 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -36,6 +36,7 @@
#include "print.h"
#include "external_commands.h"
#include "prefs.h"
+#include "file_browser.h"
static void create_document_in_new_tab (const gchar *path, const gchar *text,
const gchar *title);
@@ -50,6 +51,7 @@ static void scroll_to_cursor (void);
static gboolean find_next_match (const gchar *what, GtkSourceSearchFlags flags,
gboolean backward, GtkTextIter *match_start, GtkTextIter *match_end);
static void free_latexila (void);
+static void delete_auxiliaries_files (const gchar *filename);
static gboolean save_list_opened_docs = FALSE;
@@ -1057,6 +1059,8 @@ close_document (gint index)
g_ptr_array_add (latexila.prefs.list_opened_docs,
(gpointer) g_strdup (latexila.active_doc->path));
+ delete_auxiliaries_files (latexila.active_doc->path);
+
print_info ("close the file \"%s\"", latexila.active_doc->path);
g_free (latexila.active_doc->path);
}
@@ -1378,3 +1382,28 @@ free_latexila (void)
for (int i = 0 ; i < 7 ; i++)
g_object_unref (latexila.symbols.list_stores[i]);
}
+
+static void
+delete_auxiliaries_files (const gchar *filename)
+{
+ if (! g_str_has_suffix (filename, ".tex"))
+ return;
+
+ gchar *extensions[] = {".aux", ".bit", ".blg", ".bbl", ".lof", ".log", ".lot",
+ ".glo", ".glx", ".gxg", ".gxs", ".idx", ".ilg", ".ind", ".out", ".url",
+ ".svn", ".toc"};
+ gint nb_extensions = G_N_ELEMENTS (extensions);
+
+ gchar *filename_without_ext = g_strndup (filename, strlen (filename) - 4);
+
+ for (int i = 0 ; i < nb_extensions ; i++)
+ {
+ gchar *tmp = g_strdup_printf ("%s%s", filename_without_ext,
+ extensions[i]);
+ g_remove (tmp);
+ g_free (tmp);
+ }
+
+ g_free (filename_without_ext);
+ cb_file_browser_refresh (NULL, NULL);
+}
diff --git a/src/external_commands.c b/src/external_commands.c
index 26a0405..d57b733 100644
--- a/src/external_commands.c
+++ b/src/external_commands.c
@@ -31,6 +31,7 @@
#include "config.h"
#include "external_commands.h"
#include "print.h"
+#include "file_browser.h"
static gchar * get_command_line (gchar **command);
static void command_running_finished (void);
@@ -75,6 +76,8 @@ command_running_finished (void)
guint context_id = gtk_statusbar_get_context_id (latexila.statusbar,
"running-action");
gtk_statusbar_pop (latexila.statusbar, context_id);
+
+ cb_file_browser_refresh (NULL, NULL);
}
static gboolean
diff --git a/src/main.h b/src/main.h
index 338e8d8..f8de3d8 100644
--- a/src/main.h
+++ b/src/main.h
@@ -94,6 +94,7 @@ typedef struct
gboolean file_browser_show_all_files;
GPtrArray *list_opened_docs;
gboolean reopen_files_on_startup;
+ gboolean delete_aux_files;
} preferences_t;
typedef struct
diff --git a/src/prefs.c b/src/prefs.c
index 88be78d..161851c 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -63,6 +63,7 @@ static gchar *command_latex_ = COMMAND_LATEX;
static gchar *command_pdflatex_ = COMMAND_PDFLATEX;
static gchar *command_dvipdf_ = COMMAND_DVIPDF;
static gchar *command_dvips_ = COMMAND_DVIPS;
+static gboolean delete_aux_files_ = FALSE;
static gboolean reopen_files_on_startup_ = TRUE;
static gboolean file_browser_show_all_files_ = FALSE;
@@ -315,6 +316,16 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
+ prefs->delete_aux_files = g_key_file_get_boolean (key_file,
+ PROGRAM_NAME, "delete_auxiliaries_files", &error);
+ if (error != NULL)
+ {
+ print_warning ("%s", error->message);
+ prefs->delete_aux_files = delete_aux_files_;
+ g_error_free (error);
+ error = NULL;
+ }
+
print_info ("load user preferences: OK");
g_key_file_free (key_file);
}
@@ -354,6 +365,8 @@ save_preferences (preferences_t *prefs)
prefs->reopen_files_on_startup);
g_key_file_set_boolean (key_file, PROGRAM_NAME, "file_browser_show_all_files",
prefs->file_browser_show_all_files);
+ g_key_file_set_boolean (key_file, PROGRAM_NAME, "delete_auxiliaries_files",
+ prefs->delete_aux_files);
/* set the keys that must be taken from the widgets */
GdkWindowState flag = gdk_window_get_state (gtk_widget_get_window (
@@ -446,6 +459,7 @@ load_default_preferences (preferences_t *prefs)
prefs->list_opened_docs = g_ptr_array_new ();
prefs->reopen_files_on_startup = reopen_files_on_startup_;
prefs->file_browser_show_all_files = file_browser_show_all_files_;
+ prefs->delete_aux_files = delete_aux_files_;
set_current_font_prefs (prefs);
}
@@ -572,6 +586,12 @@ cb_file_browser_show_all_files (GtkToggleButton *toggle_button,
cb_file_browser_refresh (NULL, NULL);
}
+static void
+cb_delete_aux_files (GtkToggleButton *toggle_button, gpointer user_data)
+{
+ latexila.prefs.delete_aux_files =
+ gtk_toggle_button_get_active (toggle_button);
+}
static void
create_preferences (void)
@@ -686,6 +706,17 @@ create_preferences (void)
G_CALLBACK (cb_file_browser_show_all_files), NULL);
gtk_box_pack_start (GTK_BOX (content_area), fb_show_all_files, FALSE, FALSE, 5);
+ /* delete auxiliaries files on exit */
+ GtkWidget *delete_aux_files = gtk_check_button_new_with_label (
+ _("Clean-up auxiliaries files after close (*.aux, *.log, *.out, *.toc, etc)"));
+ gtk_widget_set_tooltip_text (delete_aux_files,
+ ".aux .bit .blg .bbl .lof .log .lot .glo .glx .gxg .gxs .idx .ilg .ind .out .url .svn
.toc");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (delete_aux_files),
+ latexila.prefs.delete_aux_files);
+ g_signal_connect (G_OBJECT (delete_aux_files), "toggled",
+ G_CALLBACK (cb_delete_aux_files), NULL);
+ gtk_box_pack_start (GTK_BOX (content_area), delete_aux_files, FALSE, FALSE, 5);
+
gtk_widget_show_all (content_area);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]