Updated Spanish translation
[anjuta-git-plugin.git] / plugins / subversion / svn-revert-command.c
blob13f2de60a6d62fccf3c785b7c3dc4da989e9bbd5
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 copy 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 "svn-revert-command.h"
27 struct _SvnRevertCommandPriv
29 GList *paths;
30 gboolean recursive;
33 G_DEFINE_TYPE (SvnRevertCommand, svn_revert_command, SVN_TYPE_COMMAND);
35 static void
36 svn_revert_command_init (SvnRevertCommand *self)
38 self->priv = g_new0 (SvnRevertCommandPriv, 1);
41 static void
42 svn_revert_command_finalize (GObject *object)
44 SvnRevertCommand *self;
46 self = SVN_REVERT_COMMAND (object);
48 svn_command_free_path_list (self->priv->paths);
49 g_free (self->priv);
51 G_OBJECT_CLASS (svn_revert_command_parent_class)->finalize (object);
54 static guint
55 svn_revert_command_run (AnjutaCommand *command)
57 SvnRevertCommand *self;
58 SvnCommand *svn_command;
59 GList *current_path;
60 apr_array_header_t *revert_paths;
61 svn_error_t *error;
63 self = SVN_REVERT_COMMAND (command);
64 svn_command = SVN_COMMAND (command);
65 current_path = self->priv->paths;
66 revert_paths = apr_array_make (svn_command_get_pool (svn_command),
67 g_list_length (self->priv->paths),
68 sizeof (char *));
70 while (current_path)
72 /* I just copied this so don't blame me... */
73 (*((const char **) apr_array_push (revert_paths))) = current_path->data;
74 current_path = g_list_next (current_path);
77 error = svn_client_revert (revert_paths,
78 self->priv->recursive,
79 svn_command_get_client_context (svn_command),
80 svn_command_get_pool (svn_command));
82 if (error)
84 svn_command_set_error (svn_command, error);
85 return 1;
88 return 0;
91 static void
92 svn_revert_command_class_init (SvnRevertCommandClass *klass)
94 GObjectClass *object_class = G_OBJECT_CLASS (klass);
95 AnjutaCommandClass *command_class = ANJUTA_COMMAND_CLASS (klass);
97 object_class->finalize = svn_revert_command_finalize;
98 command_class->run = svn_revert_command_run;
102 SvnRevertCommand *
103 svn_revert_command_new (GList *paths, gboolean recursive)
105 SvnRevertCommand *self;
107 self = g_object_new (SVN_TYPE_REVERT_COMMAND, NULL);
108 self->priv->paths = svn_command_copy_path_list (paths);
109 self->priv->recursive = recursive;
111 return self;
114 void
115 svn_revert_command_destroy (SvnRevertCommand *self)
117 g_object_unref (self);