glade: Fix make file some files were not installed
[anjuta.git] / plugins / subversion / subversion-switch-dialog.c
blob3d468e1ef02bf02cda3dc1fda63d3b966418b653
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 #define BROWSE_BUTTON_SWITCH_DIALOG "browse_button_switch_dialog"
29 static void
30 on_switch_other_revision_radio_toggled (GtkToggleButton *toggle_button,
31 SubversionData *data)
33 GtkWidget *switch_revision_entry;
34 GtkWidget *subversion_switch;
35 gboolean active;
37 switch_revision_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
38 "switch_revision_entry"));
39 subversion_switch = GTK_WIDGET (gtk_builder_get_object (data->bxml,
40 "subversion_switch"));
41 active = gtk_toggle_button_get_active (toggle_button);
42 gtk_widget_set_sensitive (switch_revision_entry, active);
44 if (active)
46 gtk_window_set_focus (GTK_WINDOW (subversion_switch),
47 switch_revision_entry);
51 static void
52 on_switch_command_finished (AnjutaCommand *command, guint return_code,
53 Subversion *plugin)
55 AnjutaStatus *status;
57 status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell,
58 NULL);
60 anjuta_status (status, _("Subversion: Switch complete."), 5);
62 report_errors (command, return_code);
64 svn_switch_command_destroy (SVN_SWITCH_COMMAND (command));
67 static void
68 on_subversion_switch_response (GtkDialog *dialog, gint response,
69 SubversionData *data)
71 GtkWidget *switch_working_copy_entry;
72 GtkWidget *switch_url_entry;
73 GtkWidget *switch_head_revision_radio;
74 GtkWidget *switch_other_revision_radio;
75 GtkWidget *switch_revision_entry;
76 GtkWidget *switch_no_recursive_check;
77 gchar *working_copy_path;
78 gchar *branch_url;
79 gchar *revision_text;
80 glong revision;
81 SvnSwitchCommand *switch_command;
83 if (response == GTK_RESPONSE_OK)
85 switch_working_copy_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
86 "switch_working_copy_entry"));
87 switch_url_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
88 "switch_url_entry"));
89 switch_head_revision_radio = GTK_WIDGET (gtk_builder_get_object (data->bxml,
90 "switch_head_revision_radio"));
91 switch_other_revision_radio = GTK_WIDGET (gtk_builder_get_object (data->bxml,
92 "switch_other_revision_radio"));
93 switch_no_recursive_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
94 "switch_no_recursive_check"));
96 working_copy_path = gtk_editable_get_chars (GTK_EDITABLE (switch_working_copy_entry),
97 0, -1);
98 branch_url = gtk_editable_get_chars (GTK_EDITABLE (switch_url_entry),
99 0, -1);
101 if (!check_input (GTK_WIDGET (dialog), switch_working_copy_entry,
102 _("Please enter a working copy path.")))
104 return;
107 if (!check_input (GTK_WIDGET (dialog), switch_url_entry,
108 _("Please enter a branch/tag URL.")))
110 return;
113 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (switch_head_revision_radio)))
114 revision = SVN_SWITCH_REVISION_HEAD;
116 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (switch_other_revision_radio)))
118 switch_revision_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
119 "switch_revision_entry"));
121 if (!check_input (GTK_WIDGET (dialog), switch_revision_entry,
122 _("Please enter a revision.")))
124 return;
127 revision_text = gtk_editable_get_chars (GTK_EDITABLE (switch_revision_entry),
128 0, -1);
129 revision = atol (revision_text);
131 g_free (revision_text);
134 create_message_view (data->plugin);
136 switch_command = svn_switch_command_new (working_copy_path, branch_url,
137 revision,
138 !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (switch_no_recursive_check)));
140 g_signal_connect (G_OBJECT (switch_command), "command-finished",
141 G_CALLBACK (on_switch_command_finished),
142 data->plugin);
144 g_signal_connect (G_OBJECT (switch_command), "data-arrived",
145 G_CALLBACK (on_command_info_arrived),
146 data->plugin);
148 anjuta_command_start (ANJUTA_COMMAND (switch_command));
151 gtk_widget_destroy (GTK_WIDGET (dialog));
152 subversion_data_free (data);
155 static void
156 subversion_switch_dialog (GtkAction *action, Subversion *plugin)
158 GtkBuilder *bxml = gtk_builder_new ();
159 GtkWidget *subversion_switch;
160 GtkWidget *switch_working_copy_entry;
161 GtkWidget *switch_other_revision_radio;
162 GtkWidget *button;
163 SubversionData *data;
164 GError* error = NULL;
166 if (!gtk_builder_add_from_file (bxml, GLADE_FILE, &error))
168 g_warning ("Couldn't load builder file: %s", error->message);
169 g_error_free (error);
172 subversion_switch = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_switch"));
173 switch_working_copy_entry = GTK_WIDGET (gtk_builder_get_object (bxml,
174 "switch_working_copy_entry"));
175 switch_other_revision_radio = GTK_WIDGET (gtk_builder_get_object (bxml,
176 "switch_other_revision_radio"));
178 data = subversion_data_new (plugin, bxml);
180 button = GTK_WIDGET (gtk_builder_get_object (bxml, BROWSE_BUTTON_SWITCH_DIALOG));
181 g_signal_connect(G_OBJECT(button), "clicked",
182 G_CALLBACK(on_subversion_browse_button_clicked), switch_working_copy_entry);
184 g_signal_connect (G_OBJECT (subversion_switch), "response",
185 G_CALLBACK (on_subversion_switch_response),
186 data);
188 g_signal_connect (G_OBJECT (switch_other_revision_radio), "toggled",
189 G_CALLBACK (on_switch_other_revision_radio_toggled),
190 data);
192 if (plugin->project_root_dir)
194 gtk_entry_set_text (GTK_ENTRY (switch_working_copy_entry),
195 plugin->project_root_dir);
198 gtk_widget_show (subversion_switch);
201 void
202 on_menu_subversion_switch (GtkAction *action, Subversion *plugin)
204 subversion_switch_dialog (action, plugin);