[anjuta/libgit2-glib: 2/5] libanjuta: Make anjuta_task_is_running virtual
- From: James Liggett <jrliggett src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/libgit2-glib: 2/5] libanjuta: Make anjuta_task_is_running virtual
- Date: Mon, 1 Jul 2013 06:55:51 +0000 (UTC)
commit c58eb359d41db7cccb98d9f959b3c37e4e2cb600
Author: James Liggett <jrliggett cox net>
Date: Fri Jun 28 21:31:06 2013 -0700
libanjuta: Make anjuta_task_is_running virtual
Let task implementations handle this because they know how to best determine if
the task is running, with thread safety if needed.
libanjuta/anjuta-task.c | 40 +++-------------------------------------
libanjuta/anjuta-task.h | 1 +
2 files changed, 4 insertions(+), 37 deletions(-)
---
diff --git a/libanjuta/anjuta-task.c b/libanjuta/anjuta-task.c
index ada1859..ef08d23 100644
--- a/libanjuta/anjuta-task.c
+++ b/libanjuta/anjuta-task.c
@@ -51,11 +51,6 @@
* For an example of how to use #AnjutaTask, see the Git plugin.
*/
-struct _AnjutaTaskPriv
-{
- gboolean running;
-};
-
enum
{
DATA_ARRIVED,
@@ -74,18 +69,11 @@ G_DEFINE_TYPE (AnjutaTask, anjuta_task, G_TYPE_OBJECT);
static void
anjuta_task_init (AnjutaTask *self)
{
- self->priv = g_new0 (AnjutaTaskPriv, 1);
}
static void
anjuta_task_finalize (GObject *object)
{
- AnjutaTask *self;
-
- self = ANJUTA_TASK (object);
-
- g_free (self->priv);
-
G_OBJECT_CLASS (anjuta_task_parent_class)->finalize (object);
}
@@ -108,13 +96,11 @@ data_arrived (AnjutaTask *task)
static void
started (AnjutaTask *task)
{
- task->priv->running = TRUE;
}
static void
finished (AnjutaTask *task)
{
- task->priv->running = FALSE;
}
static void
@@ -135,6 +121,7 @@ anjuta_task_class_init (AnjutaTaskClass *klass)
klass->notify_data_arrived = NULL;
klass->notify_finished = NULL;
klass->notify_progress = NULL;
+ klass->is_running = NULL;
klass->start_automatic_monitor = start_automatic_monitor;
klass->stop_automatic_monitor = stop_automatic_monitor;
klass->data_arrived = data_arrived;
@@ -165,14 +152,6 @@ anjuta_task_class_init (AnjutaTaskClass *klass)
*
* Indicates that a task has begun executing. This signal is intended to
* be used for tasks 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_task_signals[STARTED] =
g_signal_new ("started",
@@ -191,14 +170,6 @@ anjuta_task_class_init (AnjutaTaskClass *klass)
*
* Indicates that the task has completed. Clients should at least handle
* this signal to unref the task 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_task_signals[FINISHED] =
g_signal_new ("finished",
@@ -243,12 +214,7 @@ anjuta_task_class_init (AnjutaTaskClass *klass)
void
anjuta_task_start (AnjutaTask *self)
{
- if (!self->priv->running)
- {
- g_signal_emit_by_name (self, "task-started");
-
- ANJUTA_TASK_GET_CLASS (self)->start (self);
- }
+ ANJUTA_TASK_GET_CLASS (self)->start (self);
}
/**
@@ -314,7 +280,7 @@ anjuta_task_notify_progress (AnjutaTask *self, gfloat progress)
gboolean
anjuta_task_is_running (AnjutaTask *self)
{
- return self->priv->running;
+ return ANJUTA_TASK_GET_CLASS (self)->is_running (self);
}
/**
diff --git a/libanjuta/anjuta-task.h b/libanjuta/anjuta-task.h
index aa37597..f443f50 100644
--- a/libanjuta/anjuta-task.h
+++ b/libanjuta/anjuta-task.h
@@ -51,6 +51,7 @@ struct _AnjutaTaskClass
void (*notify_data_arrived) (AnjutaTask *self);
void (*notify_finished) (AnjutaTask *self);
void (*notify_progress) (AnjutaTask *self, gfloat progress);
+ gboolean (*is_running) (AnjutaTask *self);
gboolean (*start_automatic_monitor) (AnjutaTask *self);
void (*stop_automatic_monitor) (AnjutaTask *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]