1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Imendio AB
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
23 #include "giggle-git-add.h"
25 typedef struct GiggleGitAddPriv GiggleGitAddPriv
;
27 struct GiggleGitAddPriv
{
31 static void git_add_finalize (GObject
*object
);
32 static void git_add_get_property (GObject
*object
,
36 static void git_add_set_property (GObject
*object
,
41 static gboolean
git_add_get_command_line (GiggleJob
*job
,
42 gchar
**command_line
);
44 G_DEFINE_TYPE (GiggleGitAdd
, giggle_git_add
, GIGGLE_TYPE_JOB
)
46 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIGGLE_TYPE_GIT_ADD, GiggleGitAddPriv))
54 giggle_git_add_class_init (GiggleGitAddClass
*class)
56 GObjectClass
*object_class
= G_OBJECT_CLASS (class);
57 GiggleJobClass
*job_class
= GIGGLE_JOB_CLASS (class);
59 object_class
->finalize
= git_add_finalize
;
60 object_class
->get_property
= git_add_get_property
;
61 object_class
->set_property
= git_add_set_property
;
63 job_class
->get_command_line
= git_add_get_command_line
;
65 g_object_class_install_property (object_class
,
67 g_param_spec_pointer ("files",
69 "List of files to add",
72 g_type_class_add_private (object_class
, sizeof (GiggleGitAddPriv
));
76 giggle_git_add_init (GiggleGitAdd
*dummy
)
81 git_add_finalize (GObject
*object
)
83 GiggleGitAddPriv
*priv
;
85 priv
= GET_PRIV (object
);
87 g_list_foreach (priv
->files
, (GFunc
) g_free
, NULL
);
88 g_list_free (priv
->files
);
90 G_OBJECT_CLASS (giggle_git_add_parent_class
)->finalize (object
);
94 git_add_get_property (GObject
*object
,
99 GiggleGitAddPriv
*priv
;
101 priv
= GET_PRIV (object
);
105 g_value_set_pointer (value
, priv
->files
);
108 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
114 git_add_set_property (GObject
*object
,
119 GiggleGitAddPriv
*priv
;
121 priv
= GET_PRIV (object
);
125 priv
->files
= g_value_get_pointer (value
);
128 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
134 git_add_get_command_line (GiggleJob
*job
, gchar
**command_line
)
136 GiggleGitAddPriv
*priv
;
140 priv
= GET_PRIV (job
);
143 str
= g_string_new (GIT_COMMAND
" add");
146 g_string_append_printf (str
, " %s", (gchar
*) files
->data
);
150 *command_line
= g_string_free (str
, FALSE
);
155 giggle_git_add_new (void)
157 return g_object_new (GIGGLE_TYPE_GIT_ADD
, NULL
);
161 giggle_git_add_set_files (GiggleGitAdd
*add
,
164 g_return_if_fail (GIGGLE_IS_GIT_ADD (add
));