1 /*
2  * This file is part of d-dazzle.
3  *
4  * d-dazzle 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  * d-dazzle 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 d-dazzle; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 module dazzle.Counter;
20 
21 private import dazzle.c.functions;
22 public  import dazzle.c.types;
23 private import glib.MemorySlice;
24 private import glib.Str;
25 private import gtkd.Loader;
26 
27 
28 /** */
29 public final class Counter
30 {
31 	/** the main Gtk struct */
32 	protected DzlCounter* dzlCounter;
33 	protected bool ownedRef;
34 
35 	/** Get the main Gtk struct */
36 	public DzlCounter* getCounterStruct(bool transferOwnership = false)
37 	{
38 		if (transferOwnership)
39 			ownedRef = false;
40 		return dzlCounter;
41 	}
42 
43 	/** the main Gtk struct as a void* */
44 	protected void* getStruct()
45 	{
46 		return cast(void*)dzlCounter;
47 	}
48 
49 	/**
50 	 * Sets our main struct and passes it to the parent class.
51 	 */
52 	public this (DzlCounter* dzlCounter, bool ownedRef = false)
53 	{
54 		this.dzlCounter = dzlCounter;
55 		this.ownedRef = ownedRef;
56 	}
57 
58 	~this ()
59 	{
60 		if ( Linker.isLoaded(LIBRARY_DAZZLE) && ownedRef )
61 			sliceFree(dzlCounter);
62 	}
63 
64 
65 	/** */
66 	public @property DzlCounterValue* values()
67 	{
68 		return dzlCounter.values;
69 	}
70 
71 	/** Ditto */
72 	public @property void values(DzlCounterValue* value)
73 	{
74 		dzlCounter.values = value;
75 	}
76 
77 	/** */
78 	public @property string category()
79 	{
80 		return Str.toString(dzlCounter.category);
81 	}
82 
83 	/** Ditto */
84 	public @property void category(string value)
85 	{
86 		dzlCounter.category = Str.toStringz(value);
87 	}
88 
89 	/** */
90 	public @property string name()
91 	{
92 		return Str.toString(dzlCounter.name);
93 	}
94 
95 	/** Ditto */
96 	public @property void name(string value)
97 	{
98 		dzlCounter.name = Str.toStringz(value);
99 	}
100 
101 	/** */
102 	public @property string description()
103 	{
104 		return Str.toString(dzlCounter.description);
105 	}
106 
107 	/** Ditto */
108 	public @property void description(string value)
109 	{
110 		dzlCounter.description = Str.toStringz(value);
111 	}
112 
113 	/** */
114 	public long get()
115 	{
116 		return dzl_counter_get(dzlCounter);
117 	}
118 
119 	/** */
120 	public void reset()
121 	{
122 		dzl_counter_reset(dzlCounter);
123 	}
124 }