[gnome-latex: 93/205] Sensitivity of the actions when an action is running
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 93/205] Sensitivity of the actions when an action is running
- Date: Fri, 14 Dec 2018 10:54:42 +0000 (UTC)
commit a62646cf0e4e12537ad91fffb97cfdb01c92541f
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sat Oct 10 15:46:19 2009 +0200
Sensitivity of the actions when an action is running
New structure action_t in main.h which contain all the actions used
later in the program (now only for setting the sensitivity).
In cb_watch_output_command (), there is a new static variable
"nb_channels_active" which is set to 2, because in compile_document ()
and in convert_document (), cb_watch_output_command is used for the
output and the error output. When there is a G_IO_HUP,
nb_channels_active is decremented, and when the value is 0, we call
command_running_finished () and we reset the static variables.
If we don't do that, command_running_finished is called two times, and
the sensitivity of the actions is set to true whereas the action is
still running.
TODO | 4 ++--
src/callbacks.c | 4 ++--
src/external_commands.c | 50 +++++++++++++++++++++++++++++++++++--------------
src/main.h | 16 ++++++++++++++--
src/ui.c | 21 +++++++++++++++++++--
5 files changed, 73 insertions(+), 22 deletions(-)
---
diff --git a/TODO b/TODO
index 40c1829..facb9cf 100644
--- a/TODO
+++ b/TODO
@@ -2,8 +2,8 @@ TODO LaTeXila
Sat Oct 10, 2009 to Fri Oct 16, 2009
-[-] execution of the actions
- - sensitivity of the actions when an action is running
+[x] execution of the actions
+ x sensitivity of the actions when an action is running
[-] log zone
- keep only the 5 last actions
diff --git a/src/callbacks.c b/src/callbacks.c
index bd04ae3..a27e788 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -1097,8 +1097,8 @@ set_undo_redo_sensitivity (void)
can_redo = gtk_source_buffer_can_redo (latexila.active_doc->source_buffer);
}
- gtk_action_set_sensitive (latexila.undo, can_undo);
- gtk_action_set_sensitive (latexila.redo, can_redo);
+ gtk_action_set_sensitive (latexila.actions.undo, can_undo);
+ gtk_action_set_sensitive (latexila.actions.redo, can_redo);
}
static void
diff --git a/src/external_commands.c b/src/external_commands.c
index b0c8ea1..4f87a91 100644
--- a/src/external_commands.c
+++ b/src/external_commands.c
@@ -37,6 +37,7 @@ static void command_running_finished (void);
static gboolean cb_watch_output_command (GIOChannel *channel,
GIOCondition condition, gpointer user_data);
static void add_action (gchar *title, gchar *command);
+static void set_action_sensitivity (gboolean sensitive);
static gchar *
get_command_line (gchar **command)
@@ -66,8 +67,8 @@ command_running_finished (void)
while (gtk_events_pending ())
gtk_main_iteration ();
- // unlock the action list
- gtk_widget_set_sensitive (GTK_WIDGET (latexila.action_log.list_view), TRUE);
+ // unlock the action list and all the build actions
+ set_action_sensitivity (TRUE);
// pop the message from the statusbar
guint context_id = gtk_statusbar_get_context_id (latexila.statusbar,
@@ -80,14 +81,25 @@ cb_watch_output_command (GIOChannel *channel, GIOCondition condition,
gpointer user_data)
{
static int nb_lines = 0;
+ static int nb_channels_active = 2;
if (condition == G_IO_HUP)
{
+ print_info ("G_IO_HUP");
g_io_channel_unref (channel);
- command_running_finished ();
- nb_lines = 0;
+ nb_channels_active--;
+
+ if (nb_channels_active == 0)
+ {
+ command_running_finished ();
+ nb_lines = 0;
+ nb_channels_active = 2;
+ }
+
return FALSE;
}
+
+ print_info ("cb_watch_output_command ()");
GError *error = NULL;
gchar *line;
@@ -200,11 +212,8 @@ compile_document (gchar *title, gchar **command)
return;
}
- // Lock the action list so the user can not view an other action while the
- // compilation is running.
- // It will be unlock when the compilation is finished.
- gtk_widget_set_sensitive (GTK_WIDGET (latexila.action_log.list_view),
- FALSE);
+ // lock the action list and all the build actions
+ set_action_sensitivity (FALSE);
// add watches to channels
g_io_add_watch (out_channel, G_IO_IN | G_IO_HUP,
@@ -363,11 +372,8 @@ convert_document (gchar *title, gchar *doc_extension, gchar *command)
GIOChannel *out_channel = g_io_channel_unix_new (out);
GIOChannel *err_channel = g_io_channel_unix_new (err);
- // Lock the action list so the user can not view an other action while the
- // compilation is running.
- // It will be unlock when the compilation is finished.
- gtk_widget_set_sensitive (GTK_WIDGET (latexila.action_log.list_view),
- FALSE);
+ // lock the action list and all the build actions
+ set_action_sensitivity (FALSE);
// add watches to channels
g_io_add_watch (out_channel, G_IO_IN | G_IO_HUP,
@@ -420,3 +426,19 @@ add_action (gchar *title, gchar *command)
num++;
g_free (title2);
}
+
+static void
+set_action_sensitivity (gboolean sensitive)
+{
+ // Lock the action list when a command is running so the user can not view
+ // an other action.
+ gtk_widget_set_sensitive (GTK_WIDGET (latexila.action_log.list_view), sensitive);
+
+ gtk_action_set_sensitive (latexila.actions.compile_latex, sensitive);
+ gtk_action_set_sensitive (latexila.actions.compile_pdflatex, sensitive);
+ gtk_action_set_sensitive (latexila.actions.dvi_to_pdf, sensitive);
+ gtk_action_set_sensitive (latexila.actions.dvi_to_ps, sensitive);
+ gtk_action_set_sensitive (latexila.actions.view_dvi, sensitive);
+ gtk_action_set_sensitive (latexila.actions.view_pdf, sensitive);
+ gtk_action_set_sensitive (latexila.actions.view_ps, sensitive);
+}
diff --git a/src/main.h b/src/main.h
index cc3dd3a..34034e1 100644
--- a/src/main.h
+++ b/src/main.h
@@ -84,6 +84,19 @@ typedef struct
gchar *command_dvips;
} preferences_t;
+typedef struct
+{
+ GtkAction *undo;
+ GtkAction *redo;
+ GtkAction *compile_latex;
+ GtkAction *compile_pdflatex;
+ GtkAction *dvi_to_pdf;
+ GtkAction *dvi_to_ps;
+ GtkAction *view_dvi;
+ GtkAction *view_pdf;
+ GtkAction *view_ps;
+} actions_t;
+
typedef struct
{
GList *all_docs;
@@ -91,12 +104,11 @@ typedef struct
action_log_t action_log;
symbols_t symbols;
preferences_t prefs;
+ actions_t actions;
GtkWindow *main_window;
GtkNotebook *notebook;
GtkStatusbar *statusbar;
GtkStatusbar *cursor_position;
- GtkAction *undo;
- GtkAction *redo;
GtkPaned *main_hpaned;
GtkPaned *vpaned;
GtkPaned *log_hpaned;
diff --git a/src/ui.c b/src/ui.c
index 6ce7c53..fb80664 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -369,8 +369,25 @@ init_ui (GtkWidget *box)
gtk_ui_manager_get_accel_group (ui_manager));
// get actions
- latexila.undo = gtk_action_group_get_action (action_group, "EditUndo");
- latexila.redo = gtk_action_group_get_action (action_group, "EditRedo");
+ latexila.actions.undo = gtk_action_group_get_action (action_group,
+ "EditUndo");
+ latexila.actions.redo = gtk_action_group_get_action (action_group,
+ "EditRedo");
+ latexila.actions.compile_latex = gtk_action_group_get_action (action_group,
+ "compile_latex");
+ latexila.actions.compile_pdflatex = gtk_action_group_get_action (action_group,
+ "compile_pdflatex");
+ latexila.actions.dvi_to_pdf = gtk_action_group_get_action (action_group,
+ "DVItoPDF");
+ latexila.actions.dvi_to_ps = gtk_action_group_get_action (action_group,
+ "DVItoPS");
+ latexila.actions.view_dvi = gtk_action_group_get_action (action_group,
+ "viewDVI");
+ latexila.actions.view_pdf = gtk_action_group_get_action (action_group,
+ "viewPDF");
+ latexila.actions.view_ps = gtk_action_group_get_action (action_group,
+ "viewPS");
+
GtkToggleAction *show_symbol_tables = GTK_TOGGLE_ACTION (
gtk_action_group_get_action (action_group, "ViewSymbols"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]