1 /*
2  * This file is part of EvinceD.
3  * EvinceD is based on GtkD.
4  *
5  * EvinceD is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation; either version 3
8  * of the License, or (at your option) any later version, with
9  * some exceptions, please read the COPYING file.
10  *
11  * EvinceD 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 Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with EvinceD; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
19  */
20 
21 // generated automatically - do not change
22 // find conversion definition on APILookup.txt
23 
24 
25 module evince.view.Job;
26 
27 private import evince.view.c.functions;
28 public  import evince.view.c.types;
29 private import glib.ErrorG;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gobject.Signals;
33 private import std.algorithm;
34 
35 
36 /** */
37 public class Job : ObjectG
38 {
39 	/** the main Gtk struct */
40 	protected EvJob* evJob;
41 
42 	/** Get the main Gtk struct */
43 	public EvJob* getJobStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return evJob;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected override void* getStruct()
52 	{
53 		return cast(void*)evJob;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (EvJob* evJob, bool ownedRef = false)
60 	{
61 		this.evJob = evJob;
62 		super(cast(GObject*)evJob, ownedRef);
63 	}
64 
65 
66 	/** */
67 	public static GType getType()
68 	{
69 		return ev_job_get_type();
70 	}
71 
72 	/**
73 	 * Returns: an #EvJob
74 	 */
75 	public static Job schedulerGetRunningThreadJob()
76 	{
77 		auto __p = ev_job_scheduler_get_running_thread_job();
78 
79 		if(__p is null)
80 		{
81 			return null;
82 		}
83 
84 		return ObjectG.getDObject!(Job)(cast(EvJob*) __p);
85 	}
86 
87 	/** */
88 	public void cancel()
89 	{
90 		ev_job_cancel(evJob);
91 	}
92 
93 	/** */
94 	public void failedFromError(ErrorG error)
95 	{
96 		ev_job_failed_from_error(evJob, (error is null) ? null : error.getErrorGStruct());
97 	}
98 
99 	/** */
100 	public EvJobRunMode getRunMode()
101 	{
102 		return ev_job_get_run_mode(evJob);
103 	}
104 
105 	/** */
106 	public bool isFailed()
107 	{
108 		return ev_job_is_failed(evJob) != 0;
109 	}
110 
111 	/** */
112 	public bool isFinished()
113 	{
114 		return ev_job_is_finished(evJob) != 0;
115 	}
116 
117 	/** */
118 	public bool run()
119 	{
120 		return ev_job_run(evJob) != 0;
121 	}
122 
123 	/** */
124 	public void schedulerPushJob(EvJobPriority priority)
125 	{
126 		ev_job_scheduler_push_job(evJob, priority);
127 	}
128 
129 	/** */
130 	public void schedulerUpdateJob(EvJobPriority priority)
131 	{
132 		ev_job_scheduler_update_job(evJob, priority);
133 	}
134 
135 	/** */
136 	public void setRunMode(EvJobRunMode runMode)
137 	{
138 		ev_job_set_run_mode(evJob, runMode);
139 	}
140 
141 	/** */
142 	public void succeeded()
143 	{
144 		ev_job_succeeded(evJob);
145 	}
146 
147 	/** */
148 	gulong addOnCancelled(void delegate(Job) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
149 	{
150 		return Signals.connect(this, "cancelled", dlg, connectFlags ^ ConnectFlags.SWAPPED);
151 	}
152 
153 	/** */
154 	gulong addOnFinished(void delegate(Job) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
155 	{
156 		return Signals.connect(this, "finished", dlg, connectFlags ^ ConnectFlags.SWAPPED);
157 	}
158 }