4
* Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
#include "fm-simple-job.h"
24
static void fm_simple_job_finalize (GObject *object);
25
static gboolean fm_simple_job_run(FmJob *job);
27
G_DEFINE_TYPE(FmSimpleJob, fm_simple_job, FM_TYPE_JOB);
30
static void fm_simple_job_class_init(FmSimpleJobClass *klass)
32
GObjectClass *g_object_class;
33
FmJobClass* job_class = FM_JOB_CLASS(klass);
34
g_object_class = G_OBJECT_CLASS(klass);
35
g_object_class->finalize = fm_simple_job_finalize;
37
job_class->run = fm_simple_job_run;
41
static void fm_simple_job_finalize(GObject *object)
45
g_return_if_fail(object != NULL);
46
g_return_if_fail(FM_IS_SIMPLE_JOB(object));
48
self = FM_SIMPLE_JOB(object);
50
G_OBJECT_CLASS(fm_simple_job_parent_class)->finalize(object);
54
static void fm_simple_job_init(FmSimpleJob *self)
60
FmJob* fm_simple_job_new(FmSimpleJobFunc func, gpointer user_data)
62
FmSimpleJob* job = (FmSimpleJob*)g_object_new(FM_TYPE_SIMPLE_JOB, NULL);
64
job->user_data = user_data;
65
return (FmSimpleJob*)job;
68
static gboolean fm_simple_job_run(FmJob *job)
70
FmSimpleJob* sjob = (FmSimpleJob*)job;
71
return sjob->func ? sjob->func(sjob, sjob->user_data) : FALSE;