[anjuta/git-shell] git: Implement the Diff Stash pane



commit d30ab1139b59daf29941cae8c92fd4543ee9a1bb
Author: James Liggett <jrliggett cox net>
Date:   Wed Jul 28 00:28:53 2010 -0700

    git: Implement the Diff Stash pane

 plugins/git/Makefile.am           |    4 ++-
 plugins/git/git-diff-stash-pane.c |   69 +++++++++++++++++++++++++++++++++++++
 plugins/git/git-diff-stash-pane.h |   30 ++++++++++++++++
 plugins/git/plugin.c              |   11 +++++-
 4 files changed, 112 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 4c7eeb0..8319f63 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -207,7 +207,9 @@ libanjuta_git_la_SOURCES = \
 	git-stash-changes-pane.c \
 	git-stash-changes-pane.h \
 	git-apply-stash-pane.c \
-	git-apply-stash-pane.h
+	git-apply-stash-pane.h \
+	git-diff-stash-pane.c \
+	git-diff-stash-pane.h
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/git/git-diff-stash-pane.c b/plugins/git/git-diff-stash-pane.c
new file mode 100644
index 0000000..cfa52f3
--- /dev/null
+++ b/plugins/git/git-diff-stash-pane.c
@@ -0,0 +1,69 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * git-shell-test is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * git-shell-test is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "git-diff-stash-pane.h"
+
+void
+on_diff_stash_button_clicked (GtkAction *action, Git *plugin)
+{
+	gchar *stash;
+	GitStashShowCommand *diff_command;
+	IAnjutaDocumentManager *document_manager;
+	gint number;
+	gchar *editor_name;
+	IAnjutaEditor *editor;
+
+	stash = git_stash_pane_get_selected_stash_id (GIT_STASH_PANE (plugin->stash_pane));
+	
+	if (stash)
+	{
+		document_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
+		                                               IAnjutaDocumentManager,
+		                                               NULL);
+		number = git_stash_pane_get_selected_stash_number (GIT_STASH_PANE (plugin->stash_pane));
+		editor_name = g_strdup_printf (_("Stash %i.diff"), number);
+		editor = ianjuta_document_manager_add_buffer (document_manager, editor_name, 
+		                                              NULL, NULL);
+
+		g_free (editor_name);
+		
+
+		diff_command = git_stash_show_command_new (plugin->project_root_directory,
+		                                           stash);
+		g_free (stash);
+
+		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);
+
+		g_signal_connect (G_OBJECT (diff_command), "data-arrived",
+		                  G_CALLBACK (git_pane_send_raw_output_to_editor),
+		                  editor);
+
+		anjuta_command_start (ANJUTA_COMMAND (diff_command));
+	}
+	else
+		anjuta_util_dialog_error (NULL, _("No stash selected."));
+}
+ 
\ No newline at end of file
diff --git a/plugins/git/git-diff-stash-pane.h b/plugins/git/git-diff-stash-pane.h
new file mode 100644
index 0000000..85bf261
--- /dev/null
+++ b/plugins/git/git-diff-stash-pane.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-shell-test
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * git-shell-test is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * git-shell-test is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GIT_DIFF_STASH_PANE_H_
+#define _GIT_DIFF_STASH_PANE_H_
+
+#include <libanjuta/interfaces/ianjuta-document-manager.h>
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include "git-stash-show-command.h"
+#include "git-stash-pane.h"
+
+void on_diff_stash_button_clicked (GtkAction *action, Git *plugin);
+
+#endif
\ No newline at end of file
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 0e2371b..a8fedab 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -46,6 +46,8 @@
 #include "git-stash-pane.h"
 #include "git-stash-changes-pane.h"
 #include "git-apply-stash-pane.h"
+#include "git-diff-stash-pane.h"
+#include "git-drop-stash-pane.h"
 
 AnjutaCommandBarEntry branch_entries[] =
 {
@@ -282,8 +284,15 @@ AnjutaCommandBarEntry stash_entries[] =
 		N_("Apply stashed changes back into the working tree and the index"),
 		GTK_STOCK_OK,
 		G_CALLBACK (on_apply_stash_index_button_clicked)
+	},
+	{
+		ANJUTA_COMMAND_BAR_ENTRY_BUTTON,
+		"DiffStash",
+		N_("Diff selected stash"),
+		N_("Show a diff of the selected stash"),
+		GTK_STOCK_ZOOM_100,
+		G_CALLBACK (on_diff_stash_button_clicked)
 	}
-	
 };
 
 static gpointer parent_class;



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