Updated Spanish translation
[anjuta.git] / plugins / subversion / subversion-add-dialog.c
blob77492a20af73d951763da4d4916ea3016c4c77cd
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>
6 * Portions based on the original Subversion plugin
7 * Copyright (C) Johannes Schmid 2005
8 *
9 * anjuta is free software.
11 * You may redistribute it and/or modify it under the terms of the
12 * GNU General Public License, as published by the Free Software
13 * Foundation; either version 2 of the License, or (at your option)
14 * any later version.
16 * anjuta is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with anjuta. If not, write to:
23 * The Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor
25 * Boston, MA 02110-1301, USA.
28 #include "subversion-add-dialog.h"
30 #define BROWSE_BUTTON_ADD_DIALOG "browse_button_add_dialog"
32 static void
33 on_add_command_finished (AnjutaCommand *command, guint return_code,
34 Subversion *plugin)
36 AnjutaStatus *status;
38 status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell,
39 NULL);
41 anjuta_status (status, _("Subversion: File will be added on next "
42 "commit."), 5);
44 report_errors (command, return_code);
46 svn_add_command_destroy (SVN_ADD_COMMAND (command));
49 static void
50 on_subversion_add_response(GtkDialog* dialog, gint response, SubversionData* data)
53 switch (response)
55 case GTK_RESPONSE_OK:
57 GtkWidget* fileentry = GTK_WIDGET (gtk_builder_get_object (data->bxml, "subversion_add_filename"));
58 GtkWidget* force = GTK_WIDGET (gtk_builder_get_object (data->bxml, "subversion_force"));
59 GtkWidget* recurse = GTK_WIDGET (gtk_builder_get_object (data->bxml, "subversion_recurse"));
61 const gchar* filename = gtk_entry_get_text(GTK_ENTRY(fileentry));
62 SvnAddCommand *add_command;
64 if (!check_input (GTK_WIDGET (dialog),
65 fileentry, _("Please enter a path.")))
67 break;
70 add_command = svn_add_command_new_path ((gchar *) filename,
71 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(force)),
72 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(recurse)));
74 g_signal_connect (G_OBJECT (add_command), "command-finished",
75 G_CALLBACK (on_add_command_finished),
76 data->plugin);
78 anjuta_command_start (ANJUTA_COMMAND (add_command));
80 gtk_widget_destroy(GTK_WIDGET(dialog));
81 subversion_data_free(data);
82 break;
84 default:
86 gtk_widget_destroy (GTK_WIDGET(dialog));
87 subversion_data_free(data);
92 static void
93 subversion_add_dialog(GtkAction* action, Subversion* plugin, gchar *filename)
95 GtkBuilder* bxml = gtk_builder_new ();
96 GtkWidget* dialog;
97 GtkWidget* fileentry;
98 GtkWidget* button;
99 SubversionData* data;
100 GError* error = NULL;
102 if (!gtk_builder_add_from_file (bxml, GLADE_FILE, &error))
104 g_warning ("Couldn't load builder file: %s", error->message);
105 g_error_free (error);
108 dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_add"));
109 fileentry = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_add_filename"));
110 if (filename)
111 gtk_entry_set_text(GTK_ENTRY(fileentry), filename);
113 button = GTK_WIDGET (gtk_builder_get_object (bxml, BROWSE_BUTTON_ADD_DIALOG));
114 g_signal_connect(G_OBJECT(button), "clicked",
115 G_CALLBACK(on_subversion_browse_button_clicked), fileentry);
117 data = subversion_data_new(plugin, bxml);
118 g_signal_connect(G_OBJECT(dialog), "response",
119 G_CALLBACK(on_subversion_add_response), data);
121 gtk_widget_show(dialog);
124 void
125 on_menu_subversion_add (GtkAction* action, Subversion* plugin)
127 subversion_add_dialog(action, plugin, plugin->current_editor_filename);
130 void
131 on_fm_subversion_add (GtkAction *action, Subversion *plugin)
133 subversion_add_dialog (action, plugin, plugin->fm_current_filename);