symbol-db: emit db-connected when db is connected && with tables created.
[anjuta.git] / plugins / subversion / svn-status-command.c
blob542d7b91d9f9d721b840c9c43d09c2981a124cd0
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-status-command.h"
27 struct _SvnStatusCommandPriv
29 gchar *path;
30 gboolean recursive;
31 gboolean get_all_items;
32 GQueue *status_queue;
35 G_DEFINE_TYPE (SvnStatusCommand, svn_status_command, SVN_TYPE_COMMAND);
37 static void
38 svn_status_command_init (SvnStatusCommand *self)
40 self->priv = g_new0 (SvnStatusCommandPriv, 1);
41 self->priv->status_queue = g_queue_new ();
44 static void
45 svn_status_command_finalize (GObject *object)
47 SvnStatusCommand *self;
48 GList *current_status;
50 self = SVN_STATUS_COMMAND (object);
51 current_status = self->priv->status_queue->head;
53 g_free (self->priv->path);
55 while (current_status)
57 svn_status_destroy (current_status->data);
58 current_status = g_list_next (current_status);
61 g_queue_free (self->priv->status_queue);
62 g_free (self->priv);
64 G_OBJECT_CLASS (svn_status_command_parent_class)->finalize (object);
67 static void
68 on_svn_status_notify (void *baton, const char *path, svn_wc_status2_t *status)
70 SvnStatusCommand *self;
71 SvnStatus *status_object;
73 self = SVN_STATUS_COMMAND (baton);
75 status_object = svn_status_new ((gchar *) path,
76 status->text_status);
78 anjuta_async_command_lock (ANJUTA_ASYNC_COMMAND (self));
79 g_queue_push_tail (self->priv->status_queue, status_object);
80 anjuta_async_command_unlock (ANJUTA_ASYNC_COMMAND (self));
82 anjuta_command_notify_data_arrived (ANJUTA_COMMAND (self));
86 static guint
87 svn_status_command_run (AnjutaCommand *command)
89 SvnStatusCommand *self;
90 SvnCommand *svn_command;
91 svn_opt_revision_t revision;
92 svn_error_t *error;
94 self = SVN_STATUS_COMMAND (command);
95 svn_command = SVN_COMMAND (command);
96 revision.kind = svn_opt_revision_working;
98 error = svn_client_status2 (NULL,
99 self->priv->path,
100 &revision,
101 on_svn_status_notify,
102 self,
103 self->priv->recursive,
104 self->priv->get_all_items,
105 FALSE,
106 FALSE,
107 TRUE,
108 svn_command_get_client_context (svn_command),
109 svn_command_get_pool (svn_command));
111 if (error)
113 svn_command_set_error (svn_command, error);
114 return 1;
117 return 0;
120 static void
121 svn_status_command_class_init (SvnStatusCommandClass *klass)
123 GObjectClass *object_class = G_OBJECT_CLASS (klass);
124 AnjutaCommandClass *command_class = ANJUTA_COMMAND_CLASS (klass);
126 command_class->run = svn_status_command_run;
127 object_class->finalize = svn_status_command_finalize;
130 SvnStatusCommand *
131 svn_status_command_new (const gchar *path, gboolean recursive, gboolean get_all_items)
133 SvnStatusCommand *self;
135 self = g_object_new (SVN_TYPE_STATUS_COMMAND, NULL);
136 self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
137 path);
138 self->priv->recursive = recursive;
139 self->priv->get_all_items = get_all_items;
141 return self;
144 void
145 svn_status_command_destroy (SvnStatusCommand *self)
147 g_object_unref (self);
150 GQueue *
151 svn_status_command_get_status_queue (SvnStatusCommand *self)
153 return self->priv->status_queue;