1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
6 * anjuta is free software.
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)
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
31 gboolean get_all_items
;
35 G_DEFINE_TYPE (SvnStatusCommand
, svn_status_command
, SVN_TYPE_COMMAND
);
38 svn_status_command_init (SvnStatusCommand
*self
)
40 self
->priv
= g_new0 (SvnStatusCommandPriv
, 1);
41 self
->priv
->status_queue
= g_queue_new ();
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
);
64 G_OBJECT_CLASS (svn_status_command_parent_class
)->finalize (object
);
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
,
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
));
87 svn_status_command_run (AnjutaCommand
*command
)
89 SvnStatusCommand
*self
;
90 SvnCommand
*svn_command
;
91 svn_opt_revision_t revision
;
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
,
101 on_svn_status_notify
,
103 self
->priv
->recursive
,
104 self
->priv
->get_all_items
,
108 svn_command_get_client_context (svn_command
),
109 svn_command_get_pool (svn_command
));
113 svn_command_set_error (svn_command
, error
);
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
;
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
),
138 self
->priv
->recursive
= recursive
;
139 self
->priv
->get_all_items
= get_all_items
;
145 svn_status_command_destroy (SvnStatusCommand
*self
)
147 g_object_unref (self
);
151 svn_status_command_get_status_queue (SvnStatusCommand
*self
)
153 return self
->priv
->status_queue
;