summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2007-05-03 07:44:38 -0400
committerRay Strode <rstrode@redhat.com>2007-05-03 07:44:38 -0400
commit0cee333b2ffdf62d9beb02f822d2d042468836f2 (patch)
tree00a125eb932a9798fe7c9f3ec8c79122547d6819 /src
parent6effc888ea008a101a3fdcf6cd34110f79691dd6 (diff)
allow one action to depend on another
add pop-transaction to build system random fixups
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am12
-rw-r--r--src/pop-transaction.c49
2 files changed, 50 insertions, 11 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index cce5661..1c9c48a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,16 +15,18 @@ pop-marshal.h: pop-marshal.list $(GLIB_GENMARSHAL)
pop_demo_CFLAGS = $(POP_CFLAGS)
pop_demo_LDADD = $(POP_LIBS)
-pop_demo_SOURCES = pop-window-stack.c \
+pop_demo_SOURCES = pop-event-listener.c \
+ pop-event-listener.h \
+ pop-overlay-window.c \
+ pop-overlay-window.h \
+ pop-transaction.c \
+ pop-transaction.h \
pop-window-stack.h \
+ pop-window-stack.c \
pop-window-view.c \
pop-window-view.h \
- pop-event-listener.c \
- pop-event-listener.h \
pop-x-reply-watch.c \
pop-x-reply-watch.h \
- pop-overlay-window.c \
- pop-overlay-window.h \
$(BUILT_SOURCES) \
pop-demo.c
diff --git a/src/pop-transaction.c b/src/pop-transaction.c
index 987a080..7d52723 100644
--- a/src/pop-transaction.c
+++ b/src/pop-transaction.c
@@ -77,6 +77,7 @@ static void pop_transaction_get_property (GObject * object,
static void pop_transaction_fail (PopTransaction *transaction);
static void pop_transaction_process_on_idle (PopTransaction *transaction);
static void pop_transaction_rollback_on_idle (PopTransaction *transaction);
+static gboolean pop_transaction_rewind (PopTransaction *transaction);
enum
{
@@ -297,7 +298,19 @@ pop_transaction_add_action (PopTransaction *transaction,
action = pop_action_new (action_process_func, action_rollback_func);
- g_queue_push_tail (transaction->priv->actions, action);
+ if (transaction->priv->current_action_node == NULL)
+ g_queue_push_tail (transaction->priv->actions, action);
+ else
+ {
+ gboolean can_rewind;
+
+ g_queue_insert_before (transaction->priv->actions,
+ transaction->priv->current_action_node,
+ action);
+ can_rewind = pop_transaction_rewind (transaction);
+
+ g_assert (can_rewind);
+ }
}
static void
@@ -315,6 +328,9 @@ pop_transaction_resume (PopTransaction *transaction)
case POP_TRANSACTION_STATE_ROLLING_BACK:
pop_transaction_rollback_on_idle (transaction);
break;
+
+ default:
+ break;
}
g_source_remove (transaction->priv->wait_id);
@@ -326,7 +342,7 @@ pop_transaction_resume (PopTransaction *transaction)
static gboolean
pop_transaction_is_in_action (PopTransaction *transaction)
{
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
+ g_return_val_if_fail (POP_IS_TRANSACTION (transaction), FALSE);
if (transaction->priv->is_in_action)
{
@@ -358,6 +374,9 @@ pop_transaction_pause (PopTransaction *transaction)
g_source_remove (transaction->priv->rollback_idle_id);
transaction->priv->rollback_idle_id = 0;
break;
+
+ default:
+ break;
}
g_signal_emit (transaction, pop_transaction_signals[WAIT], 0);
@@ -412,6 +431,8 @@ pop_transaction_on_timeout_resume (gpointer data)
transaction = POP_TRANSACTION (data);
pop_transaction_resume (transaction);
+
+ return FALSE;
}
void
@@ -495,7 +516,7 @@ pop_transaction_seek_forward (PopTransaction *transaction)
static void
pop_transaction_complete (PopTransaction *transaction)
{
- GValue arguments[2] = { 0 };
+ GValue arguments[2] = { { 0 } };
g_assert (POP_IS_TRANSACTION (transaction));
@@ -679,7 +700,6 @@ pop_transaction_rollback_and_complete (PopTransaction *transaction)
static void
pop_transaction_fail (PopTransaction *transaction)
{
-
g_assert (POP_IS_TRANSACTION (transaction));
transaction->priv->status = POP_TRANSACTION_STATUS_FAILED;
@@ -735,7 +755,7 @@ pop_transaction_commit (PopTransaction *transaction)
gboolean
pop_transaction_cancel (PopTransaction *transaction)
{
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
+ g_return_val_if_fail (POP_IS_TRANSACTION (transaction), FALSE);
if (transaction->priv->status != POP_TRANSACTION_STATUS_NOT_FINISHED)
return FALSE;
@@ -765,6 +785,14 @@ on_transaction_complete (PopTransaction *transaction,
}
static PopActionProcessStatus
+preemptive_action (PopTransaction *transaction)
+{
+ g_print ("Hello World! should get printed I guess before "
+ "the transaction continues...so Hello World!\n");
+ return POP_ACTION_PROCESS_STATUS_FINISHED;
+}
+
+static PopActionProcessStatus
test_action (PopTransaction *transaction)
{
PopActionProcessStatus status;
@@ -776,6 +804,7 @@ test_action (PopTransaction *transaction)
switch (generation)
{
case 0:
+ g_print ("First instance of test action\n");
g_print ("Press enter to continue\n");
pop_transaction_wait_for_fd (transaction, fileno (stdin), G_IO_IN, NULL);
status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
@@ -794,7 +823,15 @@ test_action (PopTransaction *transaction)
break;
case 3:
- g_print ("I'm a failure.\n");
+ g_print ("Second instance of test action\n");
+ g_print ("waiting on blocking action before continuing.\n");
+ pop_transaction_add_action (transaction, preemptive_action, NULL);
+ status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
+ break;
+
+ case 4:
+ g_print ("blocking action complete.\n");
+ g_print ("failing anyway because I'm a failure.\n");
status = POP_ACTION_PROCESS_STATUS_FAILED;
break;
}