[gnome-latex: 167/205] External commands: stop execution
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 167/205] External commands: stop execution
- Date: Fri, 14 Dec 2018 11:00:55 +0000 (UTC)
commit 29934f21393be665976ac70ba39996771a58df8e
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Wed Jan 13 21:52:53 2010 +0100
External commands: stop execution
We use kill() to stop the child process.
TODO | 4 ++--
src/callbacks.c | 10 ++++++++--
src/callbacks.h | 3 ++-
src/external_commands.c | 19 +++++++++++++++----
src/external_commands.h | 1 +
src/main.h | 3 ++-
src/prefs.c | 8 ++++----
src/ui.c | 14 +++++++++++---
8 files changed, 45 insertions(+), 17 deletions(-)
---
diff --git a/TODO b/TODO
index d12f3a2..66320b4 100644
--- a/TODO
+++ b/TODO
@@ -3,12 +3,12 @@ TODO LaTeXila
- User-friendly output for the compilation
x filter the messages
x show the exit code
+ x button to stop the execution
- show statistics: nb of errors, warnings and badboxes
- extract informations: file, line, message
- - jump to lines: GtkTextBuffer -> GtkListStore
+ - jump to lines and files: GtkTextBuffer -> GtkListStore
- colors
- go to the previous/next error/warning/badbox
- - button to stop the execution
- Auto-completion of LaTeX commands
diff --git a/src/callbacks.c b/src/callbacks.c
index 0c30939..2c28711 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -721,6 +721,12 @@ cb_clean_up_build_files (void)
delete_build_files (latexila.active_doc->path);
}
+void
+cb_stop_execution (void)
+{
+ stop_execution ();
+}
+
void
cb_tools_comment (void)
{
@@ -962,7 +968,7 @@ void
cb_about_dialog (void)
{
gchar *comments = _("LaTeXila is a LaTeX editor for the GNOME Desktop");
- gchar *copyright = "Copyright © 2009, 2010 Sébastien Wilmet";
+ gchar *copyright = "Copyright (C) 2009, 2010 Sébastien Wilmet";
gchar *licence = "LaTeXila is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
@@ -994,7 +1000,7 @@ cb_about_dialog (void)
NULL
};
- GdkPixbuf *logo = gdk_pixbuf_new_from_file (DATA_DIR "/images/logo.png",
+ GdkPixbuf *logo = gdk_pixbuf_new_from_file (DATA_DIR "/images/logo/logo.png",
NULL);
gtk_show_about_dialog (
diff --git a/src/callbacks.h b/src/callbacks.h
index 53471b5..e5f4e65 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -1,7 +1,7 @@
/*
* This file is part of LaTeXila.
*
- * Copyright © 2009 Sébastien Wilmet
+ * Copyright © 2009, 2010 Sébastien Wilmet
*
* LaTeXila is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,6 +59,7 @@ void cb_dvi_to_ps (void);
void cb_bibtex (void);
void cb_makeindex (void);
void cb_clean_up_build_files (void);
+void cb_stop_execution (void);
void cb_tools_comment (void);
void cb_tools_uncomment (void);
void cb_tools_indent (void);
diff --git a/src/external_commands.c b/src/external_commands.c
index a2b320e..8487155 100644
--- a/src/external_commands.c
+++ b/src/external_commands.c
@@ -17,11 +17,14 @@
* along with LaTeXila. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _POSIX_C_SOURCE 1
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h> // for dup2
+#include <sys/types.h>
+#include <signal.h> // for kill
#include <locale.h>
#include <libintl.h>
#include <gtk/gtk.h>
@@ -52,9 +55,10 @@ static void run_command_on_other_extension (gchar *title, gchar *message,
static gboolean is_current_doc_tex_file (void);
static gboolean show_all_output = TRUE;
+static GPid child_pid;
static gint child_pid_exit_code = 0;
-static enum output output_status = OUTPUT_GO_FETCHING;
static gboolean exit_code_set = FALSE;
+static enum output output_status = OUTPUT_GO_FETCHING;
void
compile_document (gchar *title, gchar **command)
@@ -176,6 +180,13 @@ view_in_web_browser (gchar *title, gchar *filename)
start_command_without_output (command, NULL);
}
+void
+stop_execution (void)
+{
+ kill (child_pid, SIGTERM);
+ gtk_action_set_sensitive (latexila.actions.stop_execution, FALSE);
+}
+
static void
add_action (const gchar *title, const gchar *command)
{
@@ -246,6 +257,7 @@ set_action_sensitivity (gboolean sensitive)
gtk_action_set_sensitive (latexila.actions.view_ps, sensitive);
gtk_action_set_sensitive (latexila.actions.bibtex, sensitive);
gtk_action_set_sensitive (latexila.actions.makeindex, sensitive);
+ gtk_action_set_sensitive (latexila.actions.stop_execution, ! sensitive);
}
static gchar *
@@ -298,12 +310,11 @@ start_command_with_output (gchar **command)
{
gchar *dir = g_path_get_dirname (latexila.active_doc->path);
GError *error = NULL;
- GPid pid;
gint out;
g_spawn_async_with_pipes (dir, command, NULL,
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
(GSpawnChildSetupFunc) cb_spawn_setup, NULL,
- &pid, NULL, &out, NULL, &error);
+ &child_pid, NULL, &out, NULL, &error);
g_free (dir);
// an error occured
@@ -321,7 +332,7 @@ start_command_with_output (gchar **command)
exit_code_set = FALSE;
// we want to know the exit code
- g_child_watch_add (pid, (GChildWatchFunc) cb_child_watch, NULL);
+ g_child_watch_add (child_pid, (GChildWatchFunc) cb_child_watch, NULL);
// create the channel
GIOChannel *out_channel = g_io_channel_unix_new (out);
diff --git a/src/external_commands.h b/src/external_commands.h
index 91a483f..8310ee4 100644
--- a/src/external_commands.h
+++ b/src/external_commands.h
@@ -27,6 +27,7 @@ void convert_document (gchar *title, gchar *doc_extension, gchar *command);
void run_bibtex (void);
void run_makeindex (void);
void view_in_web_browser (gchar *title, gchar *filename);
+void stop_execution (void);
enum output
{
diff --git a/src/main.h b/src/main.h
index 371e712..3cbd04d 100644
--- a/src/main.h
+++ b/src/main.h
@@ -1,7 +1,7 @@
/*
* This file is part of LaTeXila.
*
- * Copyright © 2009 Sébastien Wilmet
+ * Copyright © 2009, 2010 Sébastien Wilmet
*
* LaTeXila is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -120,6 +120,7 @@ typedef struct
GtkAction *view_ps;
GtkAction *bibtex;
GtkAction *makeindex;
+ GtkAction *stop_execution;
} actions_t;
typedef struct
diff --git a/src/prefs.c b/src/prefs.c
index cb692f8..ef2ae6f 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -1,7 +1,7 @@
/*
* This file is part of LaTeXila.
*
- * Copyright © 2009 Sébastien Wilmet
+ * Copyright © 2009, 2010 Sébastien Wilmet
*
* LaTeXila is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1157,14 +1157,14 @@ create_preferences (void)
gtk_box_pack_start (GTK_BOX (vbox_latex), hbox, FALSE, FALSE, 0);
// set the same width for the labels
- // the longer label is label3
+ // the longer label is label6
GtkRequisition size;
- gtk_widget_size_request (label3, &size);
+ gtk_widget_size_request (label6, &size);
gtk_widget_set_size_request (label1, size.width, 0);
gtk_widget_set_size_request (label2, size.width, 0);
+ gtk_widget_set_size_request (label3, size.width, 0);
gtk_widget_set_size_request (label4, size.width, 0);
gtk_widget_set_size_request (label5, size.width, 0);
- gtk_widget_set_size_request (label6, size.width, 0);
// flush left
gtk_misc_set_alignment (GTK_MISC (label1), 0.0, 0.5);
diff --git a/src/ui.c b/src/ui.c
index 4327cce..77b551a 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1,7 +1,7 @@
/*
* This file is part of LaTeXila.
*
- * Copyright © 2009 Sébastien Wilmet
+ * Copyright © 2009, 2010 Sébastien Wilmet
*
* LaTeXila is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -138,6 +138,7 @@ static const char *ui =
" <menuitem action='compile_makeindex' />"
" <separator />"
" <menuitem action='clean_up_build_files' />"
+" <menuitem action='stop_execution' />"
" </menu>"
" <menu action='Latex'>"
@@ -308,6 +309,8 @@ static const char *ui =
" <separator />"
" <toolitem action='compile_pdflatex' />"
" <toolitem action='viewPDF' />"
+" <separator />"
+" <toolitem action='stop_execution' />"
" </toolbar>"
" <toolbar name='EditToolbar'>"
@@ -490,9 +493,11 @@ static GtkActionEntry entries[] = {
N_("Run BibTeX on the current document"), G_CALLBACK (cb_bibtex)},
{"compile_makeindex", NULL, "_MakeIndex", NULL,
N_("Run MakeIndex on the current document"), G_CALLBACK (cb_makeindex)},
- {"clean_up_build_files", GTK_STOCK_DELETE, N_("Cleanup Build Files"), NULL,
+ {"clean_up_build_files", GTK_STOCK_DELETE, N_("Cleanup Build _Files"), NULL,
N_("Clean-up build files (*.aux, *.log, *.out, *.toc, etc)"),
G_CALLBACK (cb_clean_up_build_files)},
+ {"stop_execution", GTK_STOCK_STOP, N_("_Stop Execution"), "<Release>F9",
+ N_("Stop Execution"), G_CALLBACK (cb_stop_execution)},
{"Tools", NULL, N_("_Tools"), NULL, NULL, NULL},
{"ToolsComment", NULL, N_("_Comment"), "<Control>D",
@@ -869,7 +874,8 @@ init_ui (GtkWidget *box)
"compile_bibtex");
latexila.actions.makeindex = gtk_action_group_get_action (action_group,
"compile_makeindex");
-
+ latexila.actions.stop_execution = gtk_action_group_get_action (action_group,
+ "stop_execution");
GtkToggleAction *show_side_pane = GTK_TOGGLE_ACTION (
gtk_action_group_get_action (action_group, "ViewSidePane"));
@@ -880,4 +886,6 @@ init_ui (GtkWidget *box)
gtk_action_group_get_action (action_group, "ViewEditToolbar"));
gtk_toggle_action_set_active (show_edit_toolbar,
latexila.prefs.show_edit_toolbar);
+
+ gtk_action_set_sensitive (latexila.actions.stop_execution, FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]