Updated Spanish translation
[anjuta-git-plugin.git] / plugins / subversion / subversion-switch-dialog.c
blob1ec4d2f4d9a253826b9a09b7e8e85b4828f51610
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
5 *
6 * anjuta is free software.
7 *
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)
11 * any later version.
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"
27 static void
28 on_switch_other_revision_radio_toggled (GtkToggleButton *toggle_button,
29 SubversionData *data)
31 GtkWidget *switch_revision_entry;
32 GtkWidget *subversion_switch;
33 gboolean active;
35 switch_revision_entry = glade_xml_get_widget (data->gxml,
36 "switch_revision_entry");
37 subversion_switch = glade_xml_get_widget (data->gxml,
38 "subversion_switch");
39 active = gtk_toggle_button_get_active (toggle_button);
40 gtk_widget_set_sensitive (switch_revision_entry, active);
42 if (active)
44 gtk_window_set_focus (GTK_WINDOW (subversion_switch),
45 switch_revision_entry);
49 static void
50 on_switch_command_finished (AnjutaCommand *command, guint return_code,
51 Subversion *plugin)
53 AnjutaStatus *status;
55 status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell,
56 NULL);
58 anjuta_status (status, _("Subversion: Switch complete."), 5);
60 report_errors (command, return_code);
62 svn_switch_command_destroy (SVN_SWITCH_COMMAND (command));
65 static void
66 on_subversion_switch_response (GtkDialog *dialog, gint response,
67 SubversionData *data)
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;
76 gchar *branch_url;
77 gchar *revision_text;
78 glong revision;
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,
86 "switch_url_entry");
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),
95 0, -1);
96 branch_url = gtk_editable_get_chars (GTK_EDITABLE (switch_url_entry),
97 0, -1);
99 if (!check_input (GTK_WIDGET (dialog), switch_working_copy_entry,
100 _("Please enter a working copy path.")))
102 return;
105 if (!check_input (GTK_WIDGET (dialog), switch_url_entry,
106 _("Please enter a branch/tag URL.")))
108 return;
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.")))
122 return;
125 revision_text = gtk_editable_get_chars (GTK_EDITABLE (switch_revision_entry),
126 0, -1);
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,
135 revision,
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),
140 data->plugin);
142 g_signal_connect (G_OBJECT (switch_command), "data-arrived",
143 G_CALLBACK (on_command_info_arrived),
144 data->plugin);
146 anjuta_command_start (ANJUTA_COMMAND (switch_command));
149 gtk_widget_destroy (GTK_WIDGET (dialog));
150 subversion_data_free (data);
153 static void
154 subversion_switch_dialog (GtkAction *action, Subversion *plugin)
156 GladeXML *gxml;
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),
173 data);
175 g_signal_connect (G_OBJECT (switch_other_revision_radio), "toggled",
176 G_CALLBACK (on_switch_other_revision_radio_toggled),
177 data);
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);
188 void
189 on_menu_subversion_switch (GtkAction *action, Subversion *plugin)
191 subversion_switch_dialog (action, plugin);