1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.ExpressionWatch;
26 
27 private import gobject.ObjectG;
28 private import gobject.Value;
29 private import gtk.c.functions;
30 public  import gtk.c.types;
31 private import gtkd.Loader;
32 
33 
34 /**
35  * An opaque structure representing a watched `GtkExpression`.
36  * 
37  * The contents of `GtkExpressionWatch` should only be accessed through the
38  * provided API.
39  */
40 public class ExpressionWatch
41 {
42 	/** the main Gtk struct */
43 	protected GtkExpressionWatch* gtkExpressionWatch;
44 	protected bool ownedRef;
45 
46 	/** Get the main Gtk struct */
47 	public GtkExpressionWatch* getExpressionWatchStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gtkExpressionWatch;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)gtkExpressionWatch;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GtkExpressionWatch* gtkExpressionWatch, bool ownedRef = false)
64 	{
65 		this.gtkExpressionWatch = gtkExpressionWatch;
66 		this.ownedRef = ownedRef;
67 	}
68 
69 	~this ()
70 	{
71 		if ( Linker.isLoaded(LIBRARY_GTK) && ownedRef )
72 			gtk_expression_watch_unref(gtkExpressionWatch);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return gtk_expression_watch_get_type();
80 	}
81 
82 	/**
83 	 * Evaluates the watched expression and on success stores the result
84 	 * in `value`.
85 	 *
86 	 * This is equivalent to calling [method@Gtk.Expression.evaluate] with the
87 	 * expression and this pointer originally used to create `watch`.
88 	 *
89 	 * Params:
90 	 *     value = an empty `GValue` to be set
91 	 *
92 	 * Returns: `TRUE` if the expression could be evaluated and `value` was set
93 	 */
94 	public bool evaluate(Value value)
95 	{
96 		return gtk_expression_watch_evaluate(gtkExpressionWatch, (value is null) ? null : value.getValueStruct()) != 0;
97 	}
98 
99 	alias doref = ref_;
100 	/**
101 	 * Acquires a reference on the given `GtkExpressionWatch`.
102 	 *
103 	 * Returns: the `GtkExpressionWatch` with an additional reference
104 	 */
105 	public ExpressionWatch ref_()
106 	{
107 		auto __p = gtk_expression_watch_ref(gtkExpressionWatch);
108 
109 		if(__p is null)
110 		{
111 			return null;
112 		}
113 
114 		return ObjectG.getDObject!(ExpressionWatch)(cast(GtkExpressionWatch*) __p, true);
115 	}
116 
117 	/**
118 	 * Releases a reference on the given `GtkExpressionWatch`.
119 	 *
120 	 * If the reference was the last, the resources associated to `self` are
121 	 * freed.
122 	 */
123 	public void unref()
124 	{
125 		gtk_expression_watch_unref(gtkExpressionWatch);
126 	}
127 
128 	/**
129 	 * Stops watching an expression.
130 	 *
131 	 * See [method@Gtk.Expression.watch] for how the watch
132 	 * was established.
133 	 */
134 	public void unwatch()
135 	{
136 		gtk_expression_watch_unwatch(gtkExpressionWatch);
137 	}
138 }