1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2007 <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 "subversion-revert-dialog.h"
28 on_revert_command_finished (AnjutaCommand
*command
, guint return_code
,
33 status
= anjuta_shell_get_status (ANJUTA_PLUGIN (plugin
)->shell
,
36 anjuta_status (status
, _("Subversion: Revert complete."), 5);
38 report_errors (command
, return_code
);
40 svn_revert_command_destroy (SVN_REVERT_COMMAND (command
));
44 on_subversion_revert_response (GtkDialog
*dialog
, gint response
,
47 SvnRevertCommand
*revert_command
;
48 GtkWidget
*revert_status_view
;
49 GList
*selected_paths
;
51 if (response
== GTK_RESPONSE_OK
)
53 revert_status_view
= GTK_WIDGET (gtk_builder_get_object (data
->bxml
,
54 "revert_status_view"));
55 selected_paths
= anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (revert_status_view
));
56 revert_command
= svn_revert_command_new_list (selected_paths
, TRUE
);
58 svn_command_free_path_list (selected_paths
);
60 g_signal_connect (G_OBJECT (revert_command
), "data-arrived",
61 G_CALLBACK (on_command_info_arrived
),
64 g_signal_connect (G_OBJECT (revert_command
), "command-finished",
65 G_CALLBACK (on_revert_command_finished
),
68 create_message_view (data
->plugin
);
70 anjuta_command_start (ANJUTA_COMMAND (revert_command
));
73 subversion_data_free (data
);
74 gtk_widget_destroy (GTK_WIDGET (dialog
));
78 subversion_revert_dialog (GtkAction
*action
, Subversion
*plugin
)
80 GtkBuilder
*bxml
= gtk_builder_new ();
81 GtkWidget
*subversion_revert
;
82 GtkWidget
*revert_select_all_button
;
83 GtkWidget
*revert_clear_button
;
84 GtkWidget
*revert_status_view
;
85 GtkWidget
*revert_status_progress_bar
;
86 SvnStatusCommand
*status_command
;
90 if (!gtk_builder_add_from_file (bxml
, GLADE_FILE
, &error
))
92 g_warning ("Couldn't load builder file: %s", error
->message
);
96 subversion_revert
= GTK_WIDGET (gtk_builder_get_object (bxml
,
97 "subversion_revert"));
98 revert_select_all_button
= GTK_WIDGET (gtk_builder_get_object (bxml
,
99 "revert_select_all_button"));
100 revert_clear_button
= GTK_WIDGET (gtk_builder_get_object (bxml
,
101 "revert_clear_button"));
102 revert_status_view
= GTK_WIDGET (gtk_builder_get_object (bxml
,
103 "revert_status_view"));
104 revert_status_progress_bar
= GTK_WIDGET (gtk_builder_get_object (bxml
,
105 "revert_status_progress_bar"));
107 status_command
= svn_status_command_new (plugin
->project_root_dir
, TRUE
,
110 data
= subversion_data_new (plugin
, bxml
);
112 g_signal_connect (G_OBJECT (subversion_revert
), "response",
113 G_CALLBACK (on_subversion_revert_response
),
116 g_signal_connect (G_OBJECT (revert_select_all_button
), "clicked",
117 G_CALLBACK (select_all_status_items
),
120 g_signal_connect (G_OBJECT (revert_clear_button
), "clicked",
121 G_CALLBACK (clear_all_status_selections
),
124 g_signal_connect (G_OBJECT (status_command
), "data-arrived",
125 G_CALLBACK (on_status_command_data_arrived
),
128 pulse_progress_bar (GTK_PROGRESS_BAR (revert_status_progress_bar
));
130 g_signal_connect (G_OBJECT (status_command
), "command-finished",
131 G_CALLBACK (cancel_data_arrived_signal_disconnect
),
134 g_signal_connect (G_OBJECT (status_command
), "command-finished",
135 G_CALLBACK (hide_pulse_progress_bar
),
136 revert_status_progress_bar
);
138 g_signal_connect (G_OBJECT (status_command
), "command-finished",
139 G_CALLBACK (on_status_command_finished
),
142 g_object_weak_ref (G_OBJECT (revert_status_view
),
143 (GWeakNotify
) disconnect_data_arrived_signals
,
146 anjuta_command_start (ANJUTA_COMMAND (status_command
));
148 gtk_dialog_run (GTK_DIALOG (subversion_revert
));
152 on_menu_subversion_revert (GtkAction
*action
, Subversion
*plugin
)
154 subversion_revert_dialog (action
, plugin
);
158 on_fm_subversion_revert (GtkAction
*action
, Subversion
*plugin
)
160 SvnRevertCommand
*revert_command
;
162 revert_command
= svn_revert_command_new_path (plugin
->fm_current_filename
, TRUE
);
164 g_signal_connect (G_OBJECT (revert_command
), "data-arrived",
165 G_CALLBACK (on_command_info_arrived
),
168 g_signal_connect (G_OBJECT (revert_command
), "command-finished",
169 G_CALLBACK (on_revert_command_finished
),
172 create_message_view (plugin
);
174 anjuta_command_start (ANJUTA_COMMAND (revert_command
));