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.document.Attachment;
26 
27 private import evince.document.c.functions;
28 public  import evince.document.c.types;
29 private import gdk.Screen;
30 private import gio.FileIF;
31 private import glib.ConstructionException;
32 private import glib.ErrorG;
33 private import glib.GException;
34 private import glib.Str;
35 private import gobject.ObjectG;
36 
37 
38 /** */
39 public class Attachment : ObjectG
40 {
41 	/** the main Gtk struct */
42 	protected EvAttachment* evAttachment;
43 
44 	/** Get the main Gtk struct */
45 	public EvAttachment* getAttachmentStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return evAttachment;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected override void* getStruct()
54 	{
55 		return cast(void*)evAttachment;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (EvAttachment* evAttachment, bool ownedRef = false)
62 	{
63 		this.evAttachment = evAttachment;
64 		super(cast(GObject*)evAttachment, ownedRef);
65 	}
66 
67 
68 	/** */
69 	public static GType getType()
70 	{
71 		return ev_attachment_get_type();
72 	}
73 
74 	/** */
75 	public this(string name, string description, GTime mtime, GTime ctime, size_t size, void* data)
76 	{
77 		auto __p = ev_attachment_new(Str.toStringz(name), Str.toStringz(description), mtime, ctime, size, data);
78 
79 		if(__p is null)
80 		{
81 			throw new ConstructionException("null returned by new");
82 		}
83 
84 		this(cast(EvAttachment*) __p, true);
85 	}
86 
87 	/** */
88 	public static GQuark errorQuark()
89 	{
90 		return ev_attachment_error_quark();
91 	}
92 
93 	/** */
94 	public GTime getCreationDate()
95 	{
96 		return ev_attachment_get_creation_date(evAttachment);
97 	}
98 
99 	/** */
100 	public string getDescription()
101 	{
102 		return Str.toString(ev_attachment_get_description(evAttachment));
103 	}
104 
105 	/** */
106 	public string getMimeType()
107 	{
108 		return Str.toString(ev_attachment_get_mime_type(evAttachment));
109 	}
110 
111 	/** */
112 	public GTime getModificationDate()
113 	{
114 		return ev_attachment_get_modification_date(evAttachment);
115 	}
116 
117 	/** */
118 	public string getName()
119 	{
120 		return Str.toString(ev_attachment_get_name(evAttachment));
121 	}
122 
123 	/** */
124 	public bool open(Screen screen, uint timestamp)
125 	{
126 		GError* err = null;
127 
128 		auto __p = ev_attachment_open(evAttachment, (screen is null) ? null : screen.getScreenStruct(), timestamp, &err) != 0;
129 
130 		if (err !is null)
131 		{
132 			throw new GException( new ErrorG(err) );
133 		}
134 
135 		return __p;
136 	}
137 
138 	/** */
139 	public bool save(FileIF file)
140 	{
141 		GError* err = null;
142 
143 		auto __p = ev_attachment_save(evAttachment, (file is null) ? null : file.getFileStruct(), &err) != 0;
144 
145 		if (err !is null)
146 		{
147 			throw new GException( new ErrorG(err) );
148 		}
149 
150 		return __p;
151 	}
152 }