~noskcaj/ubuntu/utopic/libfm/merge

« back to all changes in this revision

Viewing changes to src/job/fm-simple-job.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Lee (李健秋)
  • Date: 2010-04-29 03:52:06 UTC
  • Revision ID: james.westby@ubuntu.com-20100429035206-qlj1jwsfcgr5mdx3
Tags: upstream-0.1.11
Import upstream version 0.1.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      fm-simple-job.c
 
3
 *      
 
4
 *      Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
 
5
 *      
 
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.
 
10
 *      
 
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.
 
15
 *      
 
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,
 
19
 *      MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#include "fm-simple-job.h"
 
23
 
 
24
static void fm_simple_job_finalize                      (GObject *object);
 
25
static gboolean fm_simple_job_run(FmJob *job);
 
26
 
 
27
G_DEFINE_TYPE(FmSimpleJob, fm_simple_job, FM_TYPE_JOB);
 
28
 
 
29
 
 
30
static void fm_simple_job_class_init(FmSimpleJobClass *klass)
 
31
{
 
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;
 
36
 
 
37
        job_class->run = fm_simple_job_run;
 
38
}
 
39
 
 
40
 
 
41
static void fm_simple_job_finalize(GObject *object)
 
42
{
 
43
        FmSimpleJob *self;
 
44
 
 
45
        g_return_if_fail(object != NULL);
 
46
        g_return_if_fail(FM_IS_SIMPLE_JOB(object));
 
47
 
 
48
        self = FM_SIMPLE_JOB(object);
 
49
 
 
50
        G_OBJECT_CLASS(fm_simple_job_parent_class)->finalize(object);
 
51
}
 
52
 
 
53
 
 
54
static void fm_simple_job_init(FmSimpleJob *self)
 
55
{
 
56
        
 
57
}
 
58
 
 
59
 
 
60
FmJob*  fm_simple_job_new(FmSimpleJobFunc func, gpointer user_data)
 
61
{
 
62
    FmSimpleJob* job = (FmSimpleJob*)g_object_new(FM_TYPE_SIMPLE_JOB, NULL);
 
63
    job->func = func;
 
64
    job->user_data = user_data;
 
65
        return (FmSimpleJob*)job;
 
66
}
 
67
 
 
68
static gboolean fm_simple_job_run(FmJob *job)
 
69
{
 
70
    FmSimpleJob* sjob = (FmSimpleJob*)job;
 
71
    return sjob->func ? sjob->func(sjob, sjob->user_data) : FALSE;
 
72
}