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-unstage-dialog.h"
28 on_reset_files_command_finished (AnjutaCommand
*command
, guint return_code
,
33 status
= anjuta_shell_get_status (ANJUTA_PLUGIN (plugin
)->shell
,
36 anjuta_status (status
, _("Git: Files unstaged."), 5);
38 git_report_errors (command
, return_code
);
40 g_object_unref (command
);
45 on_unstage_dialog_response (GtkDialog
*dialog
, gint response_id
,
48 GtkWidget
*unstage_status_view
;
49 GList
*selected_paths
;
50 GitResetFilesCommand
*reset_files_command
;
52 if (response_id
== GTK_RESPONSE_OK
)
54 unstage_status_view
= glade_xml_get_widget (data
->gxml
, "unstage_status_view");
55 selected_paths
= anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (unstage_status_view
));
56 reset_files_command
= git_reset_files_command_new (data
->plugin
->project_root_directory
,
60 git_command_free_path_list (selected_paths
);
62 g_signal_connect (G_OBJECT (reset_files_command
), "command-finished",
63 G_CALLBACK (on_reset_files_command_finished
),
66 anjuta_command_start (ANJUTA_COMMAND (reset_files_command
));
69 gtk_widget_destroy (GTK_WIDGET (dialog
));
70 git_ui_data_free (data
);
74 unstage_dialog (Git
*plugin
)
78 GtkWidget
*unstage_select_all_button
;
79 GtkWidget
*unstage_clear_button
;
80 GtkWidget
*unstage_status_view
;
81 GtkWidget
*unstage_status_progress_bar
;
82 GitStatusCommand
*status_command
;
85 gxml
= glade_xml_new (GLADE_FILE
, "unstage_dialog", NULL
);
87 dialog
= glade_xml_get_widget (gxml
, "unstage_dialog");
88 unstage_select_all_button
= glade_xml_get_widget (gxml
, "unstage_select_all_button");
89 unstage_clear_button
= glade_xml_get_widget (gxml
, "unstage_clear_button");
90 unstage_status_view
= glade_xml_get_widget (gxml
, "unstage_status_view");
91 unstage_status_progress_bar
= glade_xml_get_widget (gxml
, "unstage_status_progress_bar");
93 status_command
= git_status_command_new (plugin
->project_root_directory
,
94 GIT_STATUS_SECTION_COMMIT
);
96 g_signal_connect (G_OBJECT (unstage_select_all_button
), "clicked",
97 G_CALLBACK (git_select_all_status_items
),
100 g_signal_connect (G_OBJECT (unstage_clear_button
), "clicked",
101 G_CALLBACK (git_clear_all_status_selections
),
102 unstage_status_view
);
104 git_pulse_progress_bar (GTK_PROGRESS_BAR (unstage_status_progress_bar
));
106 g_signal_connect (G_OBJECT (status_command
), "command-finished",
107 G_CALLBACK (git_cancel_data_arrived_signal_disconnect
),
108 unstage_status_view
);
110 g_signal_connect (G_OBJECT (status_command
), "command-finished",
111 G_CALLBACK (git_hide_pulse_progress_bar
),
112 unstage_status_progress_bar
);
114 g_signal_connect (G_OBJECT (status_command
), "command-finished",
115 G_CALLBACK (on_git_command_finished
),
118 g_signal_connect (G_OBJECT (status_command
), "data-arrived",
119 G_CALLBACK (on_git_status_command_data_arrived
),
120 unstage_status_view
);
122 g_object_weak_ref (G_OBJECT (unstage_status_view
),
123 (GWeakNotify
) git_disconnect_data_arrived_signals
,
126 anjuta_command_start (ANJUTA_COMMAND (status_command
));
128 data
= git_ui_data_new (plugin
, gxml
);
130 g_signal_connect(G_OBJECT (dialog
), "response",
131 G_CALLBACK (on_unstage_dialog_response
),
134 gtk_widget_show_all (dialog
);
138 on_menu_git_unstage (GtkAction
*action
, Git
*plugin
)
140 unstage_dialog (plugin
);