[gitg] Added 'cancelled' argument to runner end-loading signal
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gitg] Added 'cancelled' argument to runner end-loading signal
- Date: Sun, 5 Apr 2009 11:29:31 -0400 (EDT)
commit f698110cf96693cbc2f53dda338b6b8bd0f1178f
Author: Jesse van den Kieboom <jesse icecrew nl>
Date: Sun Apr 5 17:29:20 2009 +0200
Added 'cancelled' argument to runner end-loading signal
This allows signal handlers to detect a cancellation and act accordingly (this fixes bug #576683 and consequently debian bug #520922)
---
gitg/gitg-commit.c | 10 +++++-----
gitg/gitg-revision-view.c | 13 ++++++++-----
gitg/gitg-runner.c | 17 +++++++++--------
gitg/gitg-runner.h | 2 +-
gitg/gitg-window.c | 2 +-
5 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/gitg/gitg-commit.c b/gitg/gitg-commit.c
index b583e5c..ccdbc27 100644
--- a/gitg/gitg-commit.c
+++ b/gitg/gitg-commit.c
@@ -345,13 +345,13 @@ delete_file(GFile *key, GitgChangedFile *value, GitgCommit *commit)
}
static void
-refresh_done(GitgRunner *runner, GitgCommit *commit)
+refresh_done(GitgRunner *runner, gboolean cancelled, GitgCommit *commit)
{
g_hash_table_foreach_remove(commit->priv->files, (GHRFunc)delete_file, commit);
}
static void
-read_unstaged_files_end(GitgRunner *runner, GitgCommit *commit)
+read_unstaged_files_end(GitgRunner *runner, gboolean cancelled, GitgCommit *commit)
{
gchar *head = gitg_repository_parse_head(commit->priv->repository);
gitg_runner_cancel(runner);
@@ -368,7 +368,7 @@ read_unstaged_files_update(GitgRunner *runner, gchar **buffer, GitgCommit *commi
}
static void
-read_other_files_end(GitgRunner *runner, GitgCommit *commit)
+read_other_files_end(GitgRunner *runner, gboolean cancelled, GitgCommit *commit)
{
gitg_runner_cancel(runner);
@@ -420,7 +420,7 @@ read_other_files_update(GitgRunner *runner, gchar **buffer, GitgCommit *commit)
}
static void
-update_index_end(GitgRunner *runner, GitgCommit *commit)
+update_index_end(GitgRunner *runner, gboolean cancelled, GitgCommit *commit)
{
gitg_runner_cancel(runner);
runner_connect(commit, G_CALLBACK(read_other_files_update), G_CALLBACK(read_other_files_end));
@@ -455,7 +455,7 @@ gitg_commit_refresh(GitgCommit *commit)
if (commit->priv->repository)
update_index(commit);
else
- refresh_done(commit->priv->runner, commit);
+ refresh_done(commit->priv->runner, FALSE, commit);
}
static void
diff --git a/gitg/gitg-revision-view.c b/gitg/gitg-revision-view.c
index 330ea10..c41d495 100644
--- a/gitg/gitg-revision-view.c
+++ b/gitg/gitg-revision-view.c
@@ -442,7 +442,7 @@ on_diff_files_begin_loading(GitgRunner *runner, GitgRevisionView *self)
}
static void
-on_diff_files_end_loading(GitgRunner *runner, GitgRevisionView *self)
+on_diff_files_end_loading(GitgRunner *runner, gboolean cancelled, GitgRevisionView *self)
{
gdk_window_set_cursor(GTK_WIDGET(self->priv->diff_files)->window, NULL);
}
@@ -521,14 +521,17 @@ on_diff_begin_loading(GitgRunner *runner, GitgRevisionView *self)
}
static void
-on_diff_end_loading(GitgRunner *runner, GitgRevisionView *self)
+on_diff_end_loading(GitgRunner *runner, gboolean cancelled, GitgRevisionView *self)
{
gdk_window_set_cursor(GTK_WIDGET(self->priv->diff)->window, NULL);
- gchar *sha = gitg_revision_get_sha1(self->priv->revision);
- gitg_repository_run_commandv(self->priv->repository, self->priv->diff_files_runner, NULL,
+ if (!cancelled)
+ {
+ gchar *sha = gitg_revision_get_sha1(self->priv->revision);
+ gitg_repository_run_commandv(self->priv->repository, self->priv->diff_files_runner, NULL,
"show", "--raw", "-M", "--pretty=format:", "--abbrev=40", sha, NULL);
- g_free(sha);
+ g_free(sha);
+ }
}
static void
diff --git a/gitg/gitg-runner.c b/gitg/gitg-runner.c
index 485e45c..71fd5db 100644
--- a/gitg/gitg-runner.c
+++ b/gitg/gitg-runner.c
@@ -248,9 +248,10 @@ gitg_runner_class_init(GitgRunnerClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GitgRunnerClass, end_loading),
NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
- 0);
+ 1,
+ G_TYPE_BOOLEAN);
g_type_class_add_private(object_class, sizeof(GitgRunnerPrivate));
}
@@ -378,7 +379,7 @@ run_sync(GitgRunner *runner, gchar const *input, GError **error)
runner_io_exit(runner->priv->pid, 1, runner);
close_streams(runner);
- g_signal_emit(runner, runner_signals[END_LOADING], 0);
+ g_signal_emit(runner, runner_signals[END_LOADING], 0, FALSE);
return FALSE;
}
@@ -394,7 +395,7 @@ run_sync(GitgRunner *runner, gchar const *input, GError **error)
runner_io_exit(runner->priv->pid, 1, runner);
close_streams(runner);
- g_signal_emit(runner, runner_signals[END_LOADING], 0);
+ g_signal_emit(runner, runner_signals[END_LOADING], 0, TRUE);
return FALSE;
}
@@ -408,7 +409,7 @@ run_sync(GitgRunner *runner, gchar const *input, GError **error)
runner_io_exit(runner->priv->pid, status, runner);
close_streams(runner);
- g_signal_emit(runner, runner_signals[END_LOADING], 0);
+ g_signal_emit(runner, runner_signals[END_LOADING], 0, FALSE);
if (status != 0 && error)
g_set_error(error, GITG_RUNNER_ERROR, GITG_RUNNER_ERROR_EXIT, "Did not exit without error code");
@@ -422,7 +423,7 @@ async_failed(AsyncData *data)
runner_io_exit(data->runner->priv->pid, 1, data->runner);
close_streams(data->runner);
- g_signal_emit(data->runner, runner_signals[END_LOADING], 0);
+ g_signal_emit(data->runner, runner_signals[END_LOADING], 0, TRUE);
async_data_free(data);
}
@@ -467,7 +468,7 @@ read_output_ready(GInputStream *stream, GAsyncResult *result, AsyncData *data)
runner_io_exit(data->runner->priv->pid, status, data->runner);
close_streams(data->runner);
- g_signal_emit(data->runner, runner_signals[END_LOADING], 0);
+ g_signal_emit(data->runner, runner_signals[END_LOADING], 0, FALSE);
async_data_free(data);
}
@@ -627,7 +628,7 @@ gitg_runner_cancel(GitgRunner *runner)
runner_io_exit(runner->priv->pid, 1, runner);
close_streams(runner);
- g_signal_emit(runner, runner_signals[END_LOADING], 0);
+ g_signal_emit(runner, runner_signals[END_LOADING], 0, TRUE);
}
}
diff --git a/gitg/gitg-runner.h b/gitg/gitg-runner.h
index 6762227..d841089 100644
--- a/gitg/gitg-runner.h
+++ b/gitg/gitg-runner.h
@@ -60,7 +60,7 @@ struct _GitgRunnerClass {
/* signals */
void (* begin_loading) (GitgRunner *runner);
void (* update) (GitgRunner *runner, gchar **buffer);
- void (* end_loading) (GitgRunner *runner);
+ void (* end_loading) (GitgRunner *runner, gboolean cancelled);
};
GType gitg_runner_get_type (void) G_GNUC_CONST;
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index c0645f0..1661d36 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -484,7 +484,7 @@ on_begin_loading(GitgRunner *loader, GitgWindow *window)
}
static void
-on_end_loading(GitgRunner *loader, GitgWindow *window)
+on_end_loading(GitgRunner *loader, gboolean cancelled, GitgWindow *window)
{
gchar *msg = g_strdup_printf(_("Loaded %d revisions in %.2fs"), gtk_tree_model_iter_n_children(GTK_TREE_MODEL(window->priv->repository), NULL), g_timer_elapsed(window->priv->load_timer, NULL));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]