1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) 2004 Johannes Schmid
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "cvs-actions.h"
23 #include "cvs-execute.h"
24 #include "cvs-callbacks.h"
26 #include "glade/glade.h"
27 #include <libgnomevfs/gnome-vfs.h>
30 #include <libanjuta/anjuta-preferences.h>
31 #include <libanjuta/anjuta-utils.h>
32 #include <libanjuta/anjuta-debug.h>
34 void cvs_add_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
);
35 void cvs_remove_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
);
36 void cvs_commit_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
);
37 void cvs_update_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
);
38 void cvs_diff_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
);
39 void cvs_status_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
);
40 void cvs_log_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
);
42 static void on_server_type_changed(GtkComboBox
* combo
, GladeXML
* gxml
)
47 username
= glade_xml_get_widget(gxml
, "cvs_username");
48 password
= glade_xml_get_widget(gxml
, "cvs_password");
50 switch (gtk_combo_box_get_active(combo
))
53 gtk_widget_set_sensitive(username
, FALSE
);
54 gtk_widget_set_sensitive(password
, FALSE
);
57 gtk_widget_set_sensitive(username
, TRUE
);
58 gtk_widget_set_sensitive(password
, FALSE
);
61 gtk_widget_set_sensitive(username
, TRUE
);
62 gtk_widget_set_sensitive(password
, TRUE
);
65 DEBUG_PRINT("Unknown CVS server type");
69 static void on_diff_type_changed(GtkComboBox
* combo
, GtkWidget
* unified_check
)
71 if (gtk_combo_box_get_active(combo
) == DIFF_STANDARD
)
73 gtk_widget_set_sensitive(unified_check
, FALSE
);
75 else if (gtk_combo_box_get_active(combo
) == DIFF_PATCH
)
77 gtk_widget_set_sensitive(unified_check
, TRUE
);
80 gtk_combo_box_set_active(combo
, DIFF_STANDARD
);
83 static void init_whole_project(CVSPlugin
*plugin
, GtkWidget
* project
)
85 gboolean project_loaded
= (plugin
->project_root_dir
!= NULL
);
86 gtk_widget_set_sensitive(project
, project_loaded
);
89 static void on_whole_project_toggled(GtkToggleButton
* project
, CVSPlugin
*plugin
)
91 GtkEntry
* fileentry
= g_object_get_data (G_OBJECT (project
), "fileentry");
92 if (gtk_toggle_button_get_active(project
) && plugin
->project_root_dir
)
94 gtk_entry_set_text (fileentry
, plugin
->project_root_dir
);
95 gtk_widget_set_sensitive(GTK_WIDGET(fileentry
), FALSE
);
98 gtk_widget_set_sensitive(GTK_WIDGET(fileentry
), TRUE
);
101 void cvs_add_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
)
105 GtkWidget
* fileentry
;
107 gxml
= glade_xml_new(GLADE_FILE
, "cvs_add", NULL
);
109 dialog
= glade_xml_get_widget(gxml
, "cvs_add");
110 fileentry
= glade_xml_get_widget(gxml
, "cvs_filename");
112 gtk_entry_set_text(GTK_ENTRY(fileentry
), filename
);
114 data
= cvs_data_new(plugin
, gxml
);
115 g_signal_connect(G_OBJECT(dialog
), "response",
116 G_CALLBACK(on_cvs_add_response
), data
);
118 gtk_widget_show(dialog
);
121 void cvs_remove_dialog(GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
)
125 GtkWidget
* fileentry
;
128 gxml
= glade_xml_new(GLADE_FILE
, "cvs_remove", NULL
);
130 dialog
= glade_xml_get_widget(gxml
, "cvs_remove");
131 fileentry
= glade_xml_get_widget(gxml
, "cvs_filename");
133 gtk_entry_set_text(GTK_ENTRY(fileentry
), filename
);
135 data
= cvs_data_new(plugin
, gxml
);
136 g_signal_connect(G_OBJECT(dialog
), "response",
137 G_CALLBACK(on_cvs_remove_response
), data
);
139 gtk_widget_show(dialog
);
143 void cvs_commit_dialog (GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
)
147 GtkWidget
* fileentry
;
151 gxml
= glade_xml_new(GLADE_FILE
, "cvs_commit", NULL
);
153 dialog
= glade_xml_get_widget(gxml
, "cvs_commit");
154 fileentry
= glade_xml_get_widget(gxml
, "cvs_filename");
156 gtk_entry_set_text(GTK_ENTRY(fileentry
), filename
);
158 project
= glade_xml_get_widget(gxml
, "cvs_project");
159 g_object_set_data (G_OBJECT (project
), "fileentry", fileentry
);
160 g_signal_connect(G_OBJECT(project
), "toggled",
161 G_CALLBACK(on_whole_project_toggled
), plugin
);
162 init_whole_project(plugin
, project
);
164 data
= cvs_data_new(plugin
, gxml
);
165 g_signal_connect(G_OBJECT(dialog
), "response",
166 G_CALLBACK(on_cvs_commit_response
), data
);
168 gtk_widget_show(dialog
);
172 void cvs_update_dialog (GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
)
176 GtkWidget
* fileentry
;
180 gxml
= glade_xml_new(GLADE_FILE
, "cvs_update", NULL
);
182 dialog
= glade_xml_get_widget(gxml
, "cvs_update");
183 fileentry
= glade_xml_get_widget(gxml
, "cvs_filename");
185 gtk_entry_set_text(GTK_ENTRY(fileentry
), filename
);
187 project
= glade_xml_get_widget(gxml
, "cvs_project");
188 g_object_set_data (G_OBJECT (project
), "fileentry", fileentry
);
189 g_signal_connect(G_OBJECT(project
), "toggled",
190 G_CALLBACK(on_whole_project_toggled
), plugin
);
191 init_whole_project(plugin
, project
);
193 data
= cvs_data_new(plugin
, gxml
);
194 g_signal_connect(G_OBJECT(dialog
), "response",
195 G_CALLBACK(on_cvs_update_response
), data
);
197 gtk_widget_show(dialog
);
200 void cvs_diff_dialog (GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
)
204 GtkWidget
* fileentry
;
205 GtkWidget
* diff_type
;
206 GtkWidget
* unified_diff
;
210 gxml
= glade_xml_new(GLADE_FILE
, "cvs_diff", NULL
);
212 dialog
= glade_xml_get_widget(gxml
, "cvs_diff");
213 fileentry
= glade_xml_get_widget(gxml
, "cvs_filename");
215 gtk_entry_set_text(GTK_ENTRY(fileentry
), filename
);
217 project
= glade_xml_get_widget(gxml
, "cvs_project");
218 g_object_set_data (G_OBJECT (project
), "fileentry", fileentry
);
219 g_signal_connect(G_OBJECT(project
), "toggled",
220 G_CALLBACK(on_whole_project_toggled
), plugin
);
221 init_whole_project(plugin
, project
);
223 diff_type
= glade_xml_get_widget(gxml
, "cvs_diff_type");
224 unified_diff
= glade_xml_get_widget(gxml
, "cvs_unified");
225 gtk_combo_box_set_active(GTK_COMBO_BOX(diff_type
), DIFF_PATCH
);
226 g_signal_connect(G_OBJECT(diff_type
), "changed",
227 G_CALLBACK(on_diff_type_changed
), unified_diff
);
229 data
= cvs_data_new(plugin
, gxml
);
230 g_signal_connect(G_OBJECT(dialog
), "response",
231 G_CALLBACK(on_cvs_diff_response
), data
);
233 gtk_widget_show(dialog
);
236 void cvs_status_dialog (GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
)
240 GtkWidget
* fileentry
;
244 gxml
= glade_xml_new(GLADE_FILE
, "cvs_status", NULL
);
246 dialog
= glade_xml_get_widget(gxml
, "cvs_status");
247 fileentry
= glade_xml_get_widget(gxml
, "cvs_filename");
249 gtk_entry_set_text(GTK_ENTRY(fileentry
), filename
);
251 project
= glade_xml_get_widget(gxml
, "cvs_project");
252 g_object_set_data (G_OBJECT (project
), "fileentry", fileentry
);
253 g_signal_connect(G_OBJECT(project
), "toggled",
254 G_CALLBACK(on_whole_project_toggled
), plugin
);
255 init_whole_project(plugin
, project
);
257 data
= cvs_data_new(plugin
, gxml
);
258 g_signal_connect(G_OBJECT(dialog
), "response",
259 G_CALLBACK(on_cvs_status_response
), data
);
261 gtk_widget_show(dialog
);
265 void cvs_log_dialog (GtkAction
* action
, CVSPlugin
* plugin
, gchar
*filename
)
269 GtkWidget
* fileentry
;
273 gxml
= glade_xml_new(GLADE_FILE
, "cvs_logdialog", NULL
);
275 dialog
= glade_xml_get_widget(gxml
, "cvs_logdialog");
276 fileentry
= glade_xml_get_widget(gxml
, "cvs_filename");
278 gtk_entry_set_text(GTK_ENTRY(fileentry
), filename
);
280 project
= glade_xml_get_widget(gxml
, "cvs_project");
281 g_object_set_data (G_OBJECT (project
), "fileentry", fileentry
);
282 g_signal_connect(G_OBJECT(project
), "toggled",
283 G_CALLBACK(on_whole_project_toggled
), plugin
);
284 init_whole_project(plugin
, project
);
286 data
= cvs_data_new(plugin
, gxml
);
287 g_signal_connect(G_OBJECT(dialog
), "response",
288 G_CALLBACK(on_cvs_log_response
), data
);
290 gtk_widget_show(dialog
);
293 void on_menu_cvs_add (GtkAction
* action
, CVSPlugin
* plugin
)
295 cvs_add_dialog(action
, plugin
, plugin
->current_editor_filename
);
298 void on_menu_cvs_remove (GtkAction
* action
, CVSPlugin
* plugin
)
300 cvs_remove_dialog(action
, plugin
, plugin
->current_editor_filename
);
303 void on_menu_cvs_commit (GtkAction
* action
, CVSPlugin
* plugin
)
305 cvs_commit_dialog(action
, plugin
, plugin
->current_editor_filename
);
308 void on_menu_cvs_update (GtkAction
* action
, CVSPlugin
* plugin
)
310 cvs_update_dialog(action
, plugin
, plugin
->current_editor_filename
);
313 void on_menu_cvs_diff (GtkAction
* action
, CVSPlugin
* plugin
)
315 cvs_diff_dialog(action
, plugin
, plugin
->current_editor_filename
);
318 void on_menu_cvs_status (GtkAction
* action
, CVSPlugin
* plugin
)
320 cvs_status_dialog(action
, plugin
, plugin
->current_editor_filename
);
323 void on_menu_cvs_import (GtkAction
* action
, CVSPlugin
* plugin
)
328 GtkWidget
* typecombo
;
331 gxml
= glade_xml_new(GLADE_FILE
, "cvs_import", NULL
);
333 dialog
= glade_xml_get_widget(gxml
, "cvs_import");
334 direntry
= glade_xml_get_widget(gxml
, "cvs_rootdir");
335 typecombo
= glade_xml_get_widget(gxml
, "cvs_server_type");
337 g_signal_connect (G_OBJECT(typecombo
), "changed",
338 G_CALLBACK(on_server_type_changed
), gxml
);
339 gtk_combo_box_set_active(GTK_COMBO_BOX(typecombo
), SERVER_LOCAL
);
341 if (plugin
->project_root_dir
)
342 gtk_entry_set_text(GTK_ENTRY(direntry
), plugin
->project_root_dir
);
344 data
= cvs_data_new(plugin
, gxml
);
345 g_signal_connect(G_OBJECT(dialog
), "response",
346 G_CALLBACK(on_cvs_import_response
), data
);
348 gtk_widget_show(dialog
);
352 void on_menu_cvs_log (GtkAction
* action
, CVSPlugin
* plugin
)
354 cvs_log_dialog(action
, plugin
, plugin
->current_editor_filename
);
357 void on_fm_cvs_commit (GtkAction
* action
, CVSPlugin
* plugin
)
359 cvs_commit_dialog(action
, plugin
, plugin
->fm_current_filename
);
362 void on_fm_cvs_update (GtkAction
* action
, CVSPlugin
* plugin
)
364 cvs_update_dialog(action
, plugin
, plugin
->fm_current_filename
);
367 void on_fm_cvs_diff (GtkAction
* action
, CVSPlugin
* plugin
)
369 cvs_diff_dialog(action
, plugin
, plugin
->fm_current_filename
);
372 void on_fm_cvs_status (GtkAction
* action
, CVSPlugin
* plugin
)
374 cvs_status_dialog(action
, plugin
, plugin
->fm_current_filename
);
377 void on_fm_cvs_log (GtkAction
* action
, CVSPlugin
* plugin
)
379 cvs_log_dialog(action
, plugin
, plugin
->fm_current_filename
);