1 module webkit2.GeolocationPosition;
2 
3 private import glib.ConstructionException;
4 private import gobject.ObjectG;
5 private import webkit2.c.functions;
6 public  import webkit2.c.types;
7 
8 
9 /**
10  * WebKitGeolocationPosition is an opaque struct used to provide position updates to a
11  * #WebKitGeolocationManager using webkit_geolocation_manager_update_position().
12  *
13  * Since: 2.26
14  */
15 public class GeolocationPosition
16 {
17 	/** the main Gtk struct */
18 	protected WebKitGeolocationPosition* webKitGeolocationPosition;
19 	protected bool ownedRef;
20 
21 	/** Get the main Gtk struct */
22 	public WebKitGeolocationPosition* getGeolocationPositionStruct(bool transferOwnership = false)
23 	{
24 		if (transferOwnership)
25 			ownedRef = false;
26 		return webKitGeolocationPosition;
27 	}
28 
29 	/** the main Gtk struct as a void* */
30 	protected void* getStruct()
31 	{
32 		return cast(void*)webKitGeolocationPosition;
33 	}
34 
35 	/**
36 	 * Sets our main struct and passes it to the parent class.
37 	 */
38 	public this (WebKitGeolocationPosition* webKitGeolocationPosition, bool ownedRef = false)
39 	{
40 		this.webKitGeolocationPosition = webKitGeolocationPosition;
41 		this.ownedRef = ownedRef;
42 	}
43 
44 	~this ()
45 	{
46 		if ( ownedRef )
47 			webkit_geolocation_position_free(webKitGeolocationPosition);
48 	}
49 
50 
51 	/** */
52 	public static GType getType()
53 	{
54 		return webkit_geolocation_position_get_type();
55 	}
56 
57 	/**
58 	 * Create a new #WebKitGeolocationPosition
59 	 *
60 	 * Params:
61 	 *     latitude = a valid latitude in degrees
62 	 *     longitude = a valid longitude in degrees
63 	 *     accuracy = accuracy of location in meters
64 	 *
65 	 * Returns: a newly created #WebKitGeolocationPosition
66 	 *
67 	 * Since: 2.26
68 	 *
69 	 * Throws: ConstructionException GTK+ fails to create the object.
70 	 */
71 	public this(double latitude, double longitude, double accuracy)
72 	{
73 		auto __p = webkit_geolocation_position_new(latitude, longitude, accuracy);
74 
75 		if(__p is null)
76 		{
77 			throw new ConstructionException("null returned by new");
78 		}
79 
80 		this(cast(WebKitGeolocationPosition*) __p);
81 	}
82 
83 	/**
84 	 * Make a copy of the #WebKitGeolocationPosition
85 	 *
86 	 * Returns: a copy of @position
87 	 *
88 	 * Since: 2.26
89 	 */
90 	public GeolocationPosition copy()
91 	{
92 		auto __p = webkit_geolocation_position_copy(webKitGeolocationPosition);
93 
94 		if(__p is null)
95 		{
96 			return null;
97 		}
98 
99 		return ObjectG.getDObject!(GeolocationPosition)(cast(WebKitGeolocationPosition*) __p, true);
100 	}
101 
102 	/**
103 	 * Free the #WebKitGeolocationPosition
104 	 *
105 	 * Since: 2.26
106 	 */
107 	public void free()
108 	{
109 		webkit_geolocation_position_free(webKitGeolocationPosition);
110 		ownedRef = false;
111 	}
112 
113 	/**
114 	 * Set the @position altitude
115 	 *
116 	 * Params:
117 	 *     altitude = altitude in meters
118 	 *
119 	 * Since: 2.26
120 	 */
121 	public void setAltitude(double altitude)
122 	{
123 		webkit_geolocation_position_set_altitude(webKitGeolocationPosition, altitude);
124 	}
125 
126 	/**
127 	 * Set the accuracy of @position altitude
128 	 *
129 	 * Params:
130 	 *     altitudeAccuracy = accuracy of position altitude in meters
131 	 *
132 	 * Since: 2.26
133 	 */
134 	public void setAltitudeAccuracy(double altitudeAccuracy)
135 	{
136 		webkit_geolocation_position_set_altitude_accuracy(webKitGeolocationPosition, altitudeAccuracy);
137 	}
138 
139 	/**
140 	 * Set the @position heading, as a positive angle between the direction of movement and the North
141 	 * direction, in clockwise direction.
142 	 *
143 	 * Params:
144 	 *     heading = heading in degrees
145 	 *
146 	 * Since: 2.26
147 	 */
148 	public void setHeading(double heading)
149 	{
150 		webkit_geolocation_position_set_heading(webKitGeolocationPosition, heading);
151 	}
152 
153 	/**
154 	 * Set the @position speed
155 	 *
156 	 * Params:
157 	 *     speed = speed in meters per second
158 	 *
159 	 * Since: 2.26
160 	 */
161 	public void setSpeed(double speed)
162 	{
163 		webkit_geolocation_position_set_speed(webKitGeolocationPosition, speed);
164 	}
165 
166 	/**
167 	 * Set the @position timestamp. By default it's the time when the @position was created.
168 	 *
169 	 * Params:
170 	 *     timestamp = timestamp in seconds since the epoch, or 0 to use current time
171 	 *
172 	 * Since: 2.26
173 	 */
174 	public void setTimestamp(ulong timestamp)
175 	{
176 		webkit_geolocation_position_set_timestamp(webKitGeolocationPosition, timestamp);
177 	}
178 }