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 switch 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-switch-dialog.h"
28 on_switch_other_revision_radio_toggled (GtkToggleButton
*toggle_button
,
31 GtkWidget
*switch_revision_entry
;
32 GtkWidget
*subversion_switch
;
35 switch_revision_entry
= glade_xml_get_widget (data
->gxml
,
36 "switch_revision_entry");
37 subversion_switch
= glade_xml_get_widget (data
->gxml
,
39 active
= gtk_toggle_button_get_active (toggle_button
);
40 gtk_widget_set_sensitive (switch_revision_entry
, active
);
44 gtk_window_set_focus (GTK_WINDOW (subversion_switch
),
45 switch_revision_entry
);
50 on_switch_command_finished (AnjutaCommand
*command
, guint return_code
,
55 status
= anjuta_shell_get_status (ANJUTA_PLUGIN (plugin
)->shell
,
58 anjuta_status (status
, _("Subversion: Switch complete."), 5);
60 report_errors (command
, return_code
);
62 svn_switch_command_destroy (SVN_SWITCH_COMMAND (command
));
66 on_subversion_switch_response (GtkDialog
*dialog
, gint response
,
69 GtkWidget
*switch_working_copy_entry
;
70 GtkWidget
*switch_url_entry
;
71 GtkWidget
*switch_head_revision_radio
;
72 GtkWidget
*switch_other_revision_radio
;
73 GtkWidget
*switch_revision_entry
;
74 GtkWidget
*switch_no_recursive_check
;
75 gchar
*working_copy_path
;
79 SvnSwitchCommand
*switch_command
;
81 if (response
== GTK_RESPONSE_OK
)
83 switch_working_copy_entry
= glade_xml_get_widget (data
->gxml
,
84 "switch_working_copy_entry");
85 switch_url_entry
= glade_xml_get_widget (data
->gxml
,
87 switch_head_revision_radio
= glade_xml_get_widget (data
->gxml
,
88 "switch_head_revision_radio");
89 switch_other_revision_radio
= glade_xml_get_widget (data
->gxml
,
90 "switch_other_revision_radio");
91 switch_no_recursive_check
= glade_xml_get_widget (data
->gxml
,
92 "switch_no_recursive_check");
94 working_copy_path
= gtk_editable_get_chars (GTK_EDITABLE (switch_working_copy_entry
),
96 branch_url
= gtk_editable_get_chars (GTK_EDITABLE (switch_url_entry
),
99 if (!check_input (GTK_WIDGET (dialog
), switch_working_copy_entry
,
100 _("Please enter a working copy path.")))
105 if (!check_input (GTK_WIDGET (dialog
), switch_url_entry
,
106 _("Please enter a branch/tag URL.")))
111 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (switch_head_revision_radio
)))
112 revision
= SVN_SWITCH_REVISION_HEAD
;
114 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (switch_other_revision_radio
)))
116 switch_revision_entry
= glade_xml_get_widget (data
->gxml
,
117 "switch_revision_entry");
119 if (!check_input (GTK_WIDGET (dialog
), switch_revision_entry
,
120 _("Please enter a revision.")))
125 revision_text
= gtk_editable_get_chars (GTK_EDITABLE (switch_revision_entry
),
127 revision
= atol (revision_text
);
129 g_free (revision_text
);
132 create_message_view (data
->plugin
);
134 switch_command
= svn_switch_command_new (working_copy_path
, branch_url
,
136 !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (switch_no_recursive_check
)));
138 g_signal_connect (G_OBJECT (switch_command
), "command-finished",
139 G_CALLBACK (on_switch_command_finished
),
142 g_signal_connect (G_OBJECT (switch_command
), "data-arrived",
143 G_CALLBACK (on_command_info_arrived
),
146 anjuta_command_start (ANJUTA_COMMAND (switch_command
));
149 gtk_widget_destroy (GTK_WIDGET (dialog
));
150 subversion_data_free (data
);
154 subversion_switch_dialog (GtkAction
*action
, Subversion
*plugin
)
157 GtkWidget
*subversion_switch
;
158 GtkWidget
*switch_working_copy_entry
;
159 GtkWidget
*switch_other_revision_radio
;
160 SubversionData
*data
;
162 gxml
= glade_xml_new (GLADE_FILE
, "subversion_switch", NULL
);
163 subversion_switch
= glade_xml_get_widget (gxml
, "subversion_switch");
164 switch_working_copy_entry
= glade_xml_get_widget (gxml
,
165 "switch_working_copy_entry");
166 switch_other_revision_radio
= glade_xml_get_widget (gxml
,
167 "switch_other_revision_radio");
169 data
= subversion_data_new (plugin
, gxml
);
171 g_signal_connect (G_OBJECT (subversion_switch
), "response",
172 G_CALLBACK (on_subversion_switch_response
),
175 g_signal_connect (G_OBJECT (switch_other_revision_radio
), "toggled",
176 G_CALLBACK (on_switch_other_revision_radio_toggled
),
179 if (plugin
->project_root_dir
)
181 gtk_entry_set_text (GTK_ENTRY (switch_working_copy_entry
),
182 plugin
->project_root_dir
);
185 gtk_widget_show (subversion_switch
);
189 on_menu_subversion_switch (GtkAction
*action
, Subversion
*plugin
)
191 subversion_switch_dialog (action
, plugin
);