File: subversion-revert-dialog.c

package info (click to toggle)
anjuta 2%3A3.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 66,488 kB
  • sloc: ansic: 201,351; sh: 43,208; cpp: 11,445; makefile: 3,482; yacc: 2,757; xml: 2,570; perl: 2,087; lex: 1,526; python: 143; sql: 99; java: 7
file content (175 lines) | stat: -rw-r--r-- 5,543 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * anjuta
 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
 * 
 * anjuta is free software.
 * 
 * You may redistribute it and/or modify it under the terms of the
 * GNU General Public License, as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * 
 * anjuta 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 anjuta.  If not, write to:
 * 	The Free Software Foundation, Inc.,
 * 	51 Franklin Street, Fifth Floor
 * 	Boston, MA  02110-1301, USA.
 */

#include "subversion-revert-dialog.h"

static void
on_revert_command_finished (AnjutaCommand *command, guint return_code,
							Subversion *plugin)
{
	AnjutaStatus *status;
	
	status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell,
									  NULL);
	
	anjuta_status (status, _("Subversion: Revert complete."), 5);
	
	report_errors (command, return_code);
	
	svn_revert_command_destroy (SVN_REVERT_COMMAND (command));
}

static void
on_subversion_revert_response (GtkDialog *dialog, gint response,
							   SubversionData *data)
{
	SvnRevertCommand *revert_command;
	GtkWidget *revert_status_view;
	GList *selected_paths;
	
	if (response == GTK_RESPONSE_OK)
	{
		revert_status_view = GTK_WIDGET (gtk_builder_get_object (data->bxml,
												   "revert_status_view"));
		selected_paths = anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (revert_status_view));
		revert_command = svn_revert_command_new_list (selected_paths, TRUE);
		
		svn_command_free_path_list (selected_paths);
		
		g_signal_connect (G_OBJECT (revert_command), "data-arrived",
						  G_CALLBACK (on_command_info_arrived),
						  data->plugin);
		
		g_signal_connect (G_OBJECT (revert_command), "command-finished",
						  G_CALLBACK (on_revert_command_finished),
						  data->plugin);
		
		create_message_view (data->plugin);
		
		anjuta_command_start (ANJUTA_COMMAND (revert_command));
	}
	
	subversion_data_free (data);
	gtk_widget_destroy (GTK_WIDGET (dialog));
}

static void 
subversion_revert_dialog (GtkAction *action, Subversion *plugin)
{
	GtkBuilder *bxml = gtk_builder_new ();
	GtkWidget *subversion_revert;
	GtkWidget *revert_select_all_button;
	GtkWidget *revert_clear_button;
	GtkWidget *revert_status_view;
	GtkWidget *revert_status_progress_bar;
	SvnStatusCommand *status_command;
	SubversionData *data;
	GError* error = NULL;

	if (!gtk_builder_add_from_file (bxml, GLADE_FILE, &error))
	{
		g_warning ("Couldn't load builder file: %s", error->message);
		g_error_free (error);
	}

	subversion_revert = GTK_WIDGET (gtk_builder_get_object (bxml,
											  "subversion_revert"));
	revert_select_all_button = GTK_WIDGET (gtk_builder_get_object (bxml,
													 "revert_select_all_button"));
	revert_clear_button = GTK_WIDGET (gtk_builder_get_object (bxml,
												"revert_clear_button"));
	revert_status_view = GTK_WIDGET (gtk_builder_get_object (bxml,
											   "revert_status_view"));
	revert_status_progress_bar = GTK_WIDGET (gtk_builder_get_object (bxml,
													   "revert_status_progress_bar"));
	
	status_command = svn_status_command_new (plugin->project_root_dir, TRUE,
											 FALSE);
	
	data = subversion_data_new (plugin, bxml);
	
	g_signal_connect (G_OBJECT (subversion_revert), "response",
					  G_CALLBACK (on_subversion_revert_response),
					  data);
	
	g_signal_connect (G_OBJECT (revert_select_all_button), "clicked",
					  G_CALLBACK (select_all_status_items),
					  revert_status_view);
	
	g_signal_connect (G_OBJECT (revert_clear_button), "clicked",
					  G_CALLBACK (clear_all_status_selections),
					  revert_status_view);
	
	g_signal_connect (G_OBJECT (status_command), "data-arrived",
					  G_CALLBACK (on_status_command_data_arrived),
					  revert_status_view);
	
	pulse_progress_bar (GTK_PROGRESS_BAR (revert_status_progress_bar));
	
	g_signal_connect (G_OBJECT (status_command), "command-finished",
					  G_CALLBACK (cancel_data_arrived_signal_disconnect),
					  revert_status_view);
	
	g_signal_connect (G_OBJECT (status_command), "command-finished",
					  G_CALLBACK (hide_pulse_progress_bar),
					  revert_status_progress_bar);
	
	g_signal_connect (G_OBJECT (status_command), "command-finished",
					  G_CALLBACK (on_status_command_finished),
					  revert_status_view);
	
	g_object_weak_ref (G_OBJECT (revert_status_view),
					   (GWeakNotify) disconnect_data_arrived_signals,
					   status_command);
	
	anjuta_command_start (ANJUTA_COMMAND (status_command));
	
	gtk_dialog_run (GTK_DIALOG (subversion_revert));
}

void 
on_menu_subversion_revert (GtkAction *action, Subversion *plugin)
{
	subversion_revert_dialog (action, plugin);
}

void
on_fm_subversion_revert (GtkAction *action, Subversion *plugin)
{
	SvnRevertCommand *revert_command;
	
	revert_command = svn_revert_command_new_path (plugin->fm_current_filename, TRUE);
	
	g_signal_connect (G_OBJECT (revert_command), "data-arrived",
					  G_CALLBACK (on_command_info_arrived),
					  plugin);
	
	g_signal_connect (G_OBJECT (revert_command), "command-finished",
					  G_CALLBACK (on_revert_command_finished),
					  plugin);
	
	create_message_view (plugin);
	
	anjuta_command_start (ANJUTA_COMMAND (revert_command));
}