1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
6 * anjuta is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "git-diff-dialog.h"
27 /* FIXME: We don't really have a dialog yet. Implement that when we have an FM
28 * context menu (for diffing individual files.) A dialog isn't really needed
29 * for just getting project-wide uncommitted changes. */
32 git_diff (Git
*plugin
)
34 IAnjutaDocumentManager
*document_manager
;
35 IAnjutaEditor
*editor
;
36 GitDiffCommand
*diff_command
;
38 document_manager
= anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin
)->shell
,
39 IAnjutaDocumentManager
,
41 editor
= ianjuta_document_manager_add_buffer (document_manager
,
42 "Uncommitted Changes.diff",
45 diff_command
= git_diff_command_new (plugin
->project_root_directory
);
47 g_signal_connect (G_OBJECT (diff_command
), "data-arrived",
48 G_CALLBACK (send_raw_command_output_to_editor
),
51 g_signal_connect (G_OBJECT (diff_command
), "command_finished",
52 G_CALLBACK (on_diff_command_finished
),
55 anjuta_command_start (ANJUTA_COMMAND (diff_command
));
60 git_commit_diff (Git
*plugin
)
62 GitRevision
*revision
;
66 IAnjutaDocumentManager
*document_manager
;
67 IAnjutaEditor
*editor
;
68 GitDiffTreeCommand
*diff_command
;
70 revision
= git_log_get_selected_revision (plugin
);
74 sha
= git_revision_get_sha (revision
);
75 short_sha
= git_revision_get_short_sha (revision
);
76 editor_name
= g_strdup_printf ("Commit %s.diff", short_sha
);
78 document_manager
= anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin
)->shell
,
79 IAnjutaDocumentManager
,
81 editor
= ianjuta_document_manager_add_buffer (document_manager
,
89 diff_command
= git_diff_tree_command_new (plugin
->project_root_directory
,
92 g_signal_connect (G_OBJECT (diff_command
), "data-arrived",
93 G_CALLBACK (send_raw_command_output_to_editor
),
96 g_signal_connect (G_OBJECT (diff_command
), "command_finished",
97 G_CALLBACK (on_diff_command_finished
),
100 anjuta_command_start (ANJUTA_COMMAND (diff_command
));
105 on_menu_git_diff (GtkAction
*action
, Git
*plugin
)
111 on_log_menu_git_commit_diff (GtkAction
*action
, Git
*plugin
)
113 git_commit_diff (plugin
);