[anjuta] git: Implement revision diff viewing
- From: James Liggett <jrliggett src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] git: Implement revision diff viewing
- Date: Sun, 19 Dec 2010 01:48:12 +0000 (UTC)
commit 1202def06e442796a164d48e96d707250d2b1575
Author: James Liggett <jrliggett cox net>
Date: Sat Dec 18 17:19:43 2010 -0800
git: Implement revision diff viewing
plugins/git/git-diff-pane.c | 53 +++++++++++++++++++++++++++++++++++++++++++
plugins/git/git-diff-pane.h | 4 +++
plugins/git/git-log-pane.c | 22 +++++++++++++++++
plugins/git/git-log-pane.h | 1 +
plugins/git/plugin.c | 16 +++++++++++++
5 files changed, 96 insertions(+), 0 deletions(-)
---
diff --git a/plugins/git/git-diff-pane.c b/plugins/git/git-diff-pane.c
index 44cbde4..dfb3d30 100644
--- a/plugins/git/git-diff-pane.c
+++ b/plugins/git/git-diff-pane.c
@@ -49,4 +49,57 @@ on_diff_button_clicked (GtkAction *action, Git *plugin)
anjuta_command_start (ANJUTA_COMMAND (diff_command));
}
+
+void
+on_commit_diff_button_clicked (GtkAction *action, Git *plugin)
+{
+ GitRevision *revision;
+ gchar *sha;
+ gchar *short_sha;
+ gchar *editor_name;
+ IAnjutaDocumentManager *document_manager;
+ IAnjutaEditor *editor;
+ GitDiffTreeCommand *diff_command;
+
+ revision = git_log_pane_get_selected_revision (GIT_LOG_PANE (plugin->log_pane));
+
+ if (revision)
+ {
+ sha = git_revision_get_sha (revision);
+ short_sha = git_revision_get_short_sha (revision);
+ editor_name = g_strdup_printf ("Commit %s.diff", short_sha);
+
+ document_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
+ IAnjutaDocumentManager,
+ NULL);
+ editor = ianjuta_document_manager_add_buffer (document_manager,
+ editor_name,
+ "", NULL);
+
+ diff_command = git_diff_tree_command_new (plugin->project_root_directory,
+ sha);
+
+ g_signal_connect (G_OBJECT (diff_command), "data-arrived",
+ G_CALLBACK (git_pane_send_raw_output_to_editor),
+ editor);
+
+ g_signal_connect (G_OBJECT (diff_command), "command_finished",
+ G_CALLBACK (git_pane_report_errors),
+ plugin);
+
+ g_signal_connect (G_OBJECT (diff_command), "command_finished",
+ G_CALLBACK (g_object_unref),
+ NULL);
+
+
+ anjuta_command_start (ANJUTA_COMMAND (diff_command));
+
+ g_object_unref (revision);
+ g_free (sha);
+ g_free (short_sha);
+ g_free (editor_name);
+ }
+ else
+ anjuta_util_dialog_error (NULL, _("No revision selected"));
+}
\ No newline at end of file
diff --git a/plugins/git/git-diff-pane.h b/plugins/git/git-diff-pane.h
index 556ccb1..c24e95f 100644
--- a/plugins/git/git-diff-pane.h
+++ b/plugins/git/git-diff-pane.h
@@ -23,8 +23,12 @@
#include <libanjuta/interfaces/ianjuta-document-manager.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
#include "git-pane.h"
+#include "git-log-pane.h"
#include "git-diff-command.h"
+#include "git-diff-tree-command.h"
+#include "git-revision.h"
void on_diff_button_clicked (GtkAction *action, Git *plugin);
+void on_commit_diff_button_clicked (GtkAction *action, Git *plugin);
#endif
\ No newline at end of file
diff --git a/plugins/git/git-log-pane.c b/plugins/git/git-log-pane.c
index 1cdd0a5..e0601a8 100644
--- a/plugins/git/git-log-pane.c
+++ b/plugins/git/git-log-pane.c
@@ -1042,3 +1042,25 @@ git_log_pane_set_working_directory (GitLogPane *self,
{
/* TODO: Add public function implementation here */
}
+
+GitRevision *
+git_log_pane_get_selected_revision (GitLogPane *self)
+{
+ GtkTreeView *log_view;
+ GtkTreeSelection *selection;
+ GitRevision *revision;
+ GtkTreeIter iter;
+
+ log_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder,
+ "log_view"));
+ selection = gtk_tree_view_get_selection (log_view);
+ revision = NULL;
+
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (self->priv->log_model), &iter,
+ LOG_COL_REVISION, &revision, -1);
+ }
+
+ return revision;
+}
diff --git a/plugins/git/git-log-pane.h b/plugins/git/git-log-pane.h
index 0b112c6..95d0f95 100644
--- a/plugins/git/git-log-pane.h
+++ b/plugins/git/git-log-pane.h
@@ -57,6 +57,7 @@ GType git_log_pane_get_type (void) G_GNUC_CONST;
AnjutaDockPane *git_log_pane_new (Git *plugin);
void git_log_pane_set_working_directory (GitLogPane *self,
const gchar *working_directory);
+GitRevision *git_log_pane_get_selected_revision (GitLogPane *self);
G_END_DECLS
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index c01d538..46ec83b 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -360,6 +360,22 @@ static AnjutaCommandBarEntry log_entries[] =
{
ANJUTA_COMMAND_BAR_ENTRY_FRAME,
"NULL",
+ N_("Revision tools"),
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ ANJUTA_COMMAND_BAR_ENTRY_BUTTON,
+ "ShowCommitDiff",
+ N_("Show commit diff"),
+ N_("Show a diff of the selected revision"),
+ GTK_STOCK_ZOOM_100,
+ G_CALLBACK (on_commit_diff_button_clicked)
+ },
+ {
+ ANJUTA_COMMAND_BAR_ENTRY_FRAME,
+ "NULL",
N_("Reset/Revert"),
NULL,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]