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-revert-dialog.h"
28 on_revert_dialog_response (GtkDialog
*dialog
, gint response_id
,
31 GtkWidget
*revert_revision_entry
;
32 GtkWidget
*revert_no_commit_check
;
34 GitRevertCommand
*revert_command
;
36 if (response_id
== GTK_RESPONSE_OK
)
38 revert_revision_entry
= glade_xml_get_widget (data
->gxml
,
39 "revert_revision_entry");
40 revert_no_commit_check
= glade_xml_get_widget (data
->gxml
,
41 "revert_no_commit_check");
42 revision
= gtk_editable_get_chars (GTK_EDITABLE (revert_revision_entry
),
45 if (git_check_input (GTK_WIDGET (dialog
), revert_revision_entry
, revision
,
46 _("Please enter a revision.")))
48 revert_command
= git_revert_command_new (data
->plugin
->project_root_directory
,
50 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (revert_no_commit_check
)));
54 git_create_message_view (data
->plugin
);
56 g_signal_connect (G_OBJECT (revert_command
), "command-finished",
57 G_CALLBACK (on_git_command_finished
),
60 g_signal_connect (G_OBJECT (revert_command
), "data-arrived",
61 G_CALLBACK (on_git_command_info_arrived
),
64 anjuta_command_start (ANJUTA_COMMAND (revert_command
));
73 gtk_widget_destroy (GTK_WIDGET (dialog
));
74 git_ui_data_free (data
);
78 revert_dialog (Git
*plugin
, const gchar
*revision
)
82 GtkWidget
*revert_revision_entry
;
85 gxml
= glade_xml_new (GLADE_FILE
, "revert_dialog", NULL
);
87 dialog
= glade_xml_get_widget (gxml
, "revert_dialog");
88 revert_revision_entry
= glade_xml_get_widget (gxml
,
89 "revert_revision_entry");
91 data
= git_ui_data_new (plugin
, gxml
);
94 gtk_entry_set_text (GTK_ENTRY (revert_revision_entry
), revision
);
96 g_signal_connect (G_OBJECT (dialog
), "response",
97 G_CALLBACK (on_revert_dialog_response
),
100 gtk_widget_show_all (dialog
);
104 on_menu_git_revert (GtkAction
*action
, Git
*plugin
)
106 revert_dialog (plugin
, NULL
);
110 on_log_menu_git_revert (GtkAction
*action
, Git
*plugin
)
112 GitRevision
*revision
;
115 revision
= git_log_get_selected_revision (plugin
);
119 sha
= git_revision_get_sha (revision
);
121 revert_dialog (plugin
, sha
);