File: subversion-update-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 (154 lines) | stat: -rw-r--r-- 4,803 bytes parent folder | download | duplicates (6)
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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * anjuta
 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
 *
 * Portions based on the original Subversion plugin 
 * Copyright (C) Johannes Schmid 2005 
 * 
 * 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-update-dialog.h"

#define BROWSE_BUTTON_UPDATE_DIALOG "browse_button_update_dialog"

static void
on_update_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: Update complete."), 5);
	
	report_errors (command, return_code);
	
	svn_update_command_destroy (SVN_UPDATE_COMMAND (command));	
}

static void
on_subversion_update_response(GtkDialog* dialog, gint response, SubversionData* data)
{	
	switch (response)
	{
		case GTK_RESPONSE_OK:
		{
			const gchar* revision;
		
			GtkWidget* norecurse;
			GtkWidget* revisionentry;
			GtkWidget* fileentry = GTK_WIDGET (gtk_builder_get_object (data->bxml, "subversion_update_filename"));
			const gchar* filename = g_strdup(gtk_entry_get_text(GTK_ENTRY(fileentry)));
			SvnUpdateCommand *update_command;
			
			norecurse = GTK_WIDGET (gtk_builder_get_object (data->bxml, "subversion_update_norecurse"));
			revisionentry = GTK_WIDGET (gtk_builder_get_object (data->bxml, "subversion_revision"));
			revision = gtk_entry_get_text(GTK_ENTRY(revisionentry));
			
			if (!check_input (GTK_WIDGET (dialog), 
							  fileentry, _("Please enter a path.")))
			{
				break;
			}
			
			update_command = svn_update_command_new ((gchar *) filename, 
													 (gchar *) revision, 
													 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(norecurse)));
			create_message_view (data->plugin);
			
			g_signal_connect (G_OBJECT (update_command), "command-finished",
							  G_CALLBACK (on_update_command_finished),
							  data->plugin);

			g_signal_connect (G_OBJECT (update_command), "command-finished",
							  G_CALLBACK (subversion_plugin_status_changed_emit),
							  data->plugin);
			
			g_signal_connect (G_OBJECT (update_command), "data-arrived",
							  G_CALLBACK (on_command_info_arrived),
							  data->plugin);
			
			anjuta_command_start (ANJUTA_COMMAND (update_command));
			
			subversion_data_free(data);
			gtk_widget_destroy(GTK_WIDGET(dialog));
			break;
		}
		default:
		{
			gtk_widget_destroy(GTK_WIDGET(dialog));
			subversion_data_free(data);
			break;
		}
	}
}

static void
subversion_update_dialog (GtkAction* action, Subversion* plugin, gchar *filename)
{
	GtkBuilder* bxml = gtk_builder_new ();
	GtkWidget* dialog; 
	GtkWidget* fileentry;
	GtkWidget* project;
	GtkWidget* button;
	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);
	}

	dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_update"));
	fileentry = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_update_filename"));
	if (filename)
		gtk_entry_set_text(GTK_ENTRY(fileentry), filename);
	
	project = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_project"));
	g_object_set_data (G_OBJECT (project), "fileentry", fileentry);
	g_signal_connect(G_OBJECT(project), "toggled", 
		G_CALLBACK(on_whole_project_toggled), plugin);
	init_whole_project(plugin, project, !filename);

	button = GTK_WIDGET (gtk_builder_get_object (bxml, BROWSE_BUTTON_UPDATE_DIALOG));
	g_signal_connect(G_OBJECT(button), "clicked", 
		G_CALLBACK(on_subversion_browse_button_clicked), fileentry);

	data = subversion_data_new(plugin, bxml);
	g_signal_connect(G_OBJECT(dialog), "response", 
		G_CALLBACK(on_subversion_update_response), data);
	
	gtk_widget_show(dialog);	
}

void 
on_menu_subversion_update (GtkAction* action, Subversion* plugin)
{
	subversion_update_dialog(action, plugin, NULL);
}

void 
on_fm_subversion_update (GtkAction* action, Subversion* plugin)
{
	subversion_update_dialog(action, plugin, plugin->fm_current_filename);
}