changed the refresh hotkey
[giggle.git] / libgiggle / giggle-job.c
blobc1d2b8a1efb9d13b25a6e518c1bc53135db5cae6
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-job.h"
25 typedef struct GiggleJobPriv GiggleJobPriv;
27 struct GiggleJobPriv {
28 guint id;
31 static void job_finalize (GObject *object);
32 static void job_set_property (GObject *object,
33 guint param_id,
34 const GValue *value,
35 GParamSpec *pspec);
36 static void job_get_property (GObject *object,
37 guint param_id,
38 GValue *value,
39 GParamSpec *pspec);
41 G_DEFINE_ABSTRACT_TYPE (GiggleJob, giggle_job, G_TYPE_OBJECT)
43 enum {
44 PROP_0,
45 PROP_ID
48 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIGGLE_TYPE_JOB, GiggleJobPriv))
50 static void
51 giggle_job_class_init (GiggleJobClass *class)
53 GObjectClass *object_class = G_OBJECT_CLASS (class);
55 object_class->finalize = job_finalize;
56 object_class->get_property = job_get_property;
57 object_class->set_property = job_set_property;
59 g_object_class_install_property (object_class,
60 PROP_ID,
61 g_param_spec_uint ("id",
62 "Id",
63 "A unique identifier for the job.",
64 0, G_MAXUINT,
66 G_PARAM_READWRITE));
68 g_type_class_add_private (object_class, sizeof (GiggleJobPriv));
71 static void
72 giggle_job_init (GiggleJob *job)
74 GiggleJobPriv *priv;
76 priv = GET_PRIV (job);
78 priv->id = 0;
81 static void
82 job_finalize (GObject *object)
84 /* FIXME: Free object data */
86 G_OBJECT_CLASS (giggle_job_parent_class)->finalize (object);
89 static void
90 job_get_property (GObject *object,
91 guint param_id,
92 GValue *value,
93 GParamSpec *pspec)
95 GiggleJobPriv *priv;
97 priv = GET_PRIV (object);
99 switch (param_id) {
100 case PROP_ID:
101 g_value_set_uint (value, priv->id);
102 break;
103 default:
104 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
105 break;
109 static void
110 job_set_property (GObject *object,
111 guint param_id,
112 const GValue *value,
113 GParamSpec *pspec)
115 GiggleJobPriv *priv;
117 priv = GET_PRIV (object);
119 switch (param_id) {
120 case PROP_ID:
121 priv->id = g_value_get_uint (value);
122 break;
123 default:
124 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
125 break;
129 gboolean
130 giggle_job_get_command_line (GiggleJob *job, gchar **command_line)
132 GiggleJobClass *klass;
134 g_return_val_if_fail (GIGGLE_IS_JOB (job), FALSE);
135 g_return_val_if_fail (command_line != NULL, FALSE);
137 klass = GIGGLE_JOB_GET_CLASS (job);
138 if (klass->get_command_line) {
139 return klass->get_command_line (job, command_line);
142 *command_line = NULL;
143 return FALSE;
146 void
147 giggle_job_handle_output (GiggleJob *job,
148 const gchar *output_str,
149 gsize output_len)
151 GiggleJobClass *klass;
153 g_return_if_fail (GIGGLE_IS_JOB (job));
155 klass = GIGGLE_JOB_GET_CLASS (job);
156 if (klass->handle_output) {
157 klass->handle_output (job, output_str, output_len);