Updated Spanish translation
[anjuta.git] / plugins / subversion / svn-add-command.c
blobd8ab94dff510f1e1a80dc982fa465b3bb44dc85d
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 "svn-add-command.h"
30 struct _SvnAddCommandPriv
32 GList *paths;
33 gboolean force;
34 gboolean recursive;
37 G_DEFINE_TYPE (SvnAddCommand, svn_add_command, SVN_TYPE_COMMAND);
39 static void
40 svn_add_command_init (SvnAddCommand *self)
42 self->priv = g_new0 (SvnAddCommandPriv, 1);
45 static void
46 svn_add_command_finalize (GObject *object)
48 SvnAddCommand *self;
50 self = SVN_ADD_COMMAND (object);
52 svn_command_free_path_list (self->priv->paths);
53 g_free (self->priv);
55 G_OBJECT_CLASS (svn_add_command_parent_class)->finalize (object);
58 static guint
59 svn_add_command_run (AnjutaCommand *command)
61 SvnAddCommand *self;
62 SvnCommand *svn_command;
63 GList *current_path;
64 svn_error_t *error;
66 self = SVN_ADD_COMMAND (command);
67 svn_command = SVN_COMMAND (command);
68 current_path = self->priv->paths;
70 while (current_path)
72 error = svn_client_add2 (current_path->data,
73 self->priv->force,
74 self->priv->recursive,
75 svn_command_get_client_context (svn_command),
76 svn_command_get_pool (svn_command));
78 if (error)
80 svn_command_set_error (svn_command, error);
81 return 1;
84 current_path = g_list_next (current_path);
87 return 0;
90 static void
91 svn_add_command_class_init (SvnAddCommandClass *klass)
93 GObjectClass *object_class = G_OBJECT_CLASS (klass);
94 AnjutaCommandClass *command_class = ANJUTA_COMMAND_CLASS (klass);
96 object_class->finalize = svn_add_command_finalize;
97 command_class->run = svn_add_command_run;
101 SvnAddCommand *
102 svn_add_command_new_path (const gchar *path, gboolean force, gboolean recursive)
104 SvnAddCommand *self;
106 self = g_object_new (SVN_TYPE_ADD_COMMAND, NULL);
107 self->priv->paths = g_list_append (self->priv->paths,
108 svn_command_make_canonical_path (SVN_COMMAND (self),
109 path));
110 self->priv->force = force;
111 self->priv->recursive = recursive;
113 return self;
116 SvnAddCommand *
117 svn_add_command_new_list (GList *paths, gboolean force, gboolean recursive)
119 SvnAddCommand *self;
120 GList *current_path;
122 self = g_object_new (SVN_TYPE_ADD_COMMAND, NULL);
123 current_path = paths;
125 while (current_path)
127 self->priv->paths = g_list_append (self->priv->paths,
128 svn_command_make_canonical_path (SVN_COMMAND (self),
129 current_path->data));
130 current_path = g_list_next (current_path);
133 self->priv->force = force;
134 self->priv->recursive = recursive;
136 return self;
139 void
140 svn_add_command_destroy (SvnAddCommand *self)
142 g_object_unref (self);