[anjuta/git-shell: 227/234] libanjuta: Add a method to tell the running state of AnjutaCommands



commit 0cc04605b42f9a03291fb4621b3a48e523eed2ae
Author: James Liggett <jrliggett cox net>
Date:   Fri Apr 2 01:12:39 2010 -0700

    libanjuta: Add a method to tell the running state of AnjutaCommands

 libanjuta/anjuta-command.c |   33 ++++++++++++++++++++++++++++++++-
 libanjuta/anjuta-command.h |    1 +
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/libanjuta/anjuta-command.c b/libanjuta/anjuta-command.c
index 42b13ce..97da142 100644
--- a/libanjuta/anjuta-command.c
+++ b/libanjuta/anjuta-command.c
@@ -54,6 +54,7 @@
 
 struct _AnjutaCommandPriv
 {
+	gboolean running;
 	gchar *error_message;
 };
 
@@ -110,11 +111,13 @@ data_arrived (AnjutaCommand *command)
 static void
 command_started (AnjutaCommand *command)
 {
+	command->priv->running = TRUE;
 }
 
 static void
 command_finished (AnjutaCommand *command, guint return_code)
 {
+	command->priv->running = FALSE;
 }
 
 static void
@@ -167,6 +170,14 @@ anjuta_command_class_init (AnjutaCommandClass *klass)
 	 *
 	 * Indicates that a command has begun executing. This signal is intended to 
 	 * be used for commands that start themselves automatically.
+	 *
+	 * <note>
+	 *  <para>
+	 *	  Sublasses that override the method for this signal should chain up to
+	 *	  the parent implementation to ensure proper handling of running/not 
+	 *	  running states. 
+	 *	</para>
+	 * </note>
 	 */
 	anjuta_command_signals[COMMAND_STARTED] =
 		g_signal_new ("command-started",
@@ -184,7 +195,15 @@ anjuta_command_class_init (AnjutaCommandClass *klass)
 	 * @return_code: The return code of the finished commmand
 	 *
 	 * Indicates that the command has completed. Clients should at least handle
-	 * this signal to unref the command object. 
+	 * this signal to unref the command object.
+	 *
+	 * <note>
+	 *  <para>
+	 *	  Sublasses that override the method for this signal should chain up to
+	 *	  the parent implementation to ensure proper handling of running/not 
+	 *	  running states. 
+	 *	</para>
+	 * </note>
 	 */
 	anjuta_command_signals[COMMAND_FINISHED] =
 		g_signal_new ("command-finished",
@@ -288,6 +307,18 @@ anjuta_command_notify_progress (AnjutaCommand *self, gfloat progress)
 }
 
 /**
+ * anjuta_command_is_running:
+ * @self: Command object.
+ *
+ * Return value: %TRUE if the command is currently running; %FALSE otherwise.
+ */
+gboolean
+anjuta_command_is_running (AnjutaCommand *self)
+{
+	return self->priv->running;
+}
+
+/**
  * anjuta_command_set_error_message:
  * @self: Command object.
  * @error_message: Error message.
diff --git a/libanjuta/anjuta-command.h b/libanjuta/anjuta-command.h
index 31668cf..234758a 100644
--- a/libanjuta/anjuta-command.h
+++ b/libanjuta/anjuta-command.h
@@ -78,6 +78,7 @@ void anjuta_command_cancel (AnjutaCommand *self);
 void anjuta_command_notify_data_arrived (AnjutaCommand *self);
 void anjuta_command_notify_complete (AnjutaCommand *self, guint return_code);
 void anjuta_command_notify_progress (AnjutaCommand *self, gfloat progress);
+gboolean anjuta_command_is_running (AnjutaCommand *self);
 
 void anjuta_command_set_error_message (AnjutaCommand *self, gchar *error_message);
 gchar *anjuta_command_get_error_message (AnjutaCommand *self);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]