changed the refresh hotkey
[giggle.git] / libgiggle / giggle-git-add.c
bloba9bcb0b1af739a43f00e6db6adf053e85926d862
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
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.
21 #include <config.h>
23 #include "giggle-git-add.h"
25 typedef struct GiggleGitAddPriv GiggleGitAddPriv;
27 struct GiggleGitAddPriv {
28 GList *files;
31 static void git_add_finalize (GObject *object);
32 static void git_add_get_property (GObject *object,
33 guint param_id,
34 GValue *value,
35 GParamSpec *pspec);
36 static void git_add_set_property (GObject *object,
37 guint param_id,
38 const GValue *value,
39 GParamSpec *pspec);
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))
48 enum {
49 PROP_0,
50 PROP_FILES,
53 static void
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,
66 PROP_FILES,
67 g_param_spec_pointer ("files",
68 "Files",
69 "List of files to add",
70 G_PARAM_READWRITE));
72 g_type_class_add_private (object_class, sizeof (GiggleGitAddPriv));
75 static void
76 giggle_git_add_init (GiggleGitAdd *dummy)
80 static void
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);
93 static void
94 git_add_get_property (GObject *object,
95 guint param_id,
96 GValue *value,
97 GParamSpec *pspec)
99 GiggleGitAddPriv *priv;
101 priv = GET_PRIV (object);
103 switch (param_id) {
104 case PROP_FILES:
105 g_value_set_pointer (value, priv->files);
106 break;
107 default:
108 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
109 break;
113 static void
114 git_add_set_property (GObject *object,
115 guint param_id,
116 const GValue *value,
117 GParamSpec *pspec)
119 GiggleGitAddPriv *priv;
121 priv = GET_PRIV (object);
123 switch (param_id) {
124 case PROP_FILES:
125 priv->files = g_value_get_pointer (value);
126 break;
127 default:
128 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
129 break;
133 static gboolean
134 git_add_get_command_line (GiggleJob *job, gchar **command_line)
136 GiggleGitAddPriv *priv;
137 GString *str;
138 GList *files;
140 priv = GET_PRIV (job);
141 files = priv->files;
143 str = g_string_new (GIT_COMMAND " add");
145 while (files) {
146 g_string_append_printf (str, " %s", (gchar *) files->data);
147 files = files->next;
150 *command_line = g_string_free (str, FALSE);
151 return TRUE;
154 GiggleJob *
155 giggle_git_add_new (void)
157 return g_object_new (GIGGLE_TYPE_GIT_ADD, NULL);
160 void
161 giggle_git_add_set_files (GiggleGitAdd *add,
162 GList *files)
164 g_return_if_fail (GIGGLE_IS_GIT_ADD (add));
166 g_object_set (add,
167 "files", files,
168 NULL);