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  * Conversion parameters:
26  * inFile  = gio-Desktop-file-based-GAppInfo.html
27  * outPack = gio
28  * outFile = DesktopAppInfo
29  * strct   = GDesktopAppInfo
30  * realStrct=
31  * ctorStrct=
32  * clss    = DesktopAppInfo
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- AppInfoIF
40  * prefixes:
41  * 	- g_desktop_app_info_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * 	- g_desktop_app_info_new_from_filename
46  * omit signals:
47  * imports:
48  * 	- glib.KeyFile
49  * 	- gio.AppInfo
50  * 	- gio.AppInfoIF
51  * 	- gio.AppInfoT
52  * 	- gio.AppInfoIF
53  * structWrap:
54  * 	- GAppInfo* -> AppInfoIF
55  * 	- GKeyFile* -> KeyFile
56  * module aliases:
57  * local aliases:
58  * overrides:
59  */
60 
61 module gio.DesktopAppInfo;
62 
63 public  import gtkc.giotypes;
64 
65 private import gtkc.gio;
66 private import glib.ConstructionException;
67 private import gobject.ObjectG;
68 
69 
70 private import glib.KeyFile;
71 private import gio.AppInfo;
72 private import gio.AppInfoIF;
73 private import gio.AppInfoT;
74 private import gio.AppInfoIF;
75 
76 
77 
78 private import gobject.ObjectG;
79 
80 /**
81  * Description
82  * GDesktopAppInfo is an implementation of GAppInfo based on
83  * desktop files.
84  * Note that <gio/gdesktopappinfo.h> belongs to
85  * the UNIX-specific GIO interfaces, thus you have to use the
86  * gio-unix-2.0.pc pkg-config file when using it.
87  */
88 public class DesktopAppInfo : ObjectG, AppInfoIF
89 {
90 	
91 	/** the main Gtk struct */
92 	protected GDesktopAppInfo* gDesktopAppInfo;
93 	
94 	
95 	public GDesktopAppInfo* getDesktopAppInfoStruct()
96 	{
97 		return gDesktopAppInfo;
98 	}
99 	
100 	
101 	/** the main Gtk struct as a void* */
102 	protected override void* getStruct()
103 	{
104 		return cast(void*)gDesktopAppInfo;
105 	}
106 	
107 	/**
108 	 * Sets our main struct and passes it to the parent class
109 	 */
110 	public this (GDesktopAppInfo* gDesktopAppInfo)
111 	{
112 		super(cast(GObject*)gDesktopAppInfo);
113 		this.gDesktopAppInfo = gDesktopAppInfo;
114 	}
115 	
116 	protected override void setStruct(GObject* obj)
117 	{
118 		super.setStruct(obj);
119 		gDesktopAppInfo = cast(GDesktopAppInfo*)obj;
120 	}
121 	
122 	// add the AppInfo capabilities
123 	mixin AppInfoT!(GDesktopAppInfo);
124 	
125 	public static DesktopAppInfo createFromFilename(string filename)
126 	{
127 		auto p = g_desktop_app_info_new_from_filename(Str.toStringz(filename));
128 		
129 		if(p is null)
130 		{
131 			throw new ConstructionException("null returned by g_desktop_app_info_new_from_filename");
132 		}
133 		
134 		return new DesktopAppInfo(p);
135 	}
136 	
137 	/**
138 	 */
139 	
140 	/**
141 	 * Creates a new GDesktopAppInfo.
142 	 * Since 2.18
143 	 * Params:
144 	 * keyFile = an opened GKeyFile
145 	 * Throws: ConstructionException GTK+ fails to create the object.
146 	 */
147 	public this (KeyFile keyFile)
148 	{
149 		// GDesktopAppInfo * g_desktop_app_info_new_from_keyfile (GKeyFile *key_file);
150 		auto p = g_desktop_app_info_new_from_keyfile((keyFile is null) ? null : keyFile.getKeyFileStruct());
151 		if(p is null)
152 		{
153 			throw new ConstructionException("null returned by g_desktop_app_info_new_from_keyfile((keyFile is null) ? null : keyFile.getKeyFileStruct())");
154 		}
155 		this(cast(GDesktopAppInfo*) p);
156 	}
157 	
158 	/**
159 	 * Creates a new GDesktopAppInfo based on a desktop file id.
160 	 * A desktop file id is the basename of the desktop file, including the
161 	 * .desktop extension. GIO is looking for a desktop file with this name
162 	 * in the applications subdirectories of the XDG data
163 	 * directories (i.e. the directories specified in the
164 	 * XDG_DATA_HOME and XDG_DATA_DIRS environment
165 	 * variables). GIO also supports the prefix-to-subdirectory mapping that is
166 	 * described in the Menu Spec
167 	 * (i.e. a desktop id of kde-foo.desktop will match
168 	 * /usr/share/applications/kde/foo.desktop).
169 	 * Params:
170 	 * desktopId = the desktop file id
171 	 * Throws: ConstructionException GTK+ fails to create the object.
172 	 */
173 	public this (string desktopId)
174 	{
175 		// GDesktopAppInfo * g_desktop_app_info_new (const char *desktop_id);
176 		auto p = g_desktop_app_info_new(Str.toStringz(desktopId));
177 		if(p is null)
178 		{
179 			throw new ConstructionException("null returned by g_desktop_app_info_new(Str.toStringz(desktopId))");
180 		}
181 		this(cast(GDesktopAppInfo*) p);
182 	}
183 	
184 	/**
185 	 * When info was created from a known filename, return it. In some
186 	 * situations such as the GDesktopAppInfo returned from
187 	 * g_desktop_app_info_new_from_keyfile(), this function will return NULL.
188 	 * Since 2.24
189 	 * Returns: The full path to the file for info, or NULL if not known.
190 	 */
191 	public string getFilename()
192 	{
193 		// const char * g_desktop_app_info_get_filename (GDesktopAppInfo *info);
194 		return Str.toString(g_desktop_app_info_get_filename(gDesktopAppInfo));
195 	}
196 	
197 	/**
198 	 * A desktop file is hidden if the Hidden key in it is
199 	 * set to True.
200 	 * Returns: TRUE if hidden, FALSE otherwise.
201 	 */
202 	public int getIsHidden()
203 	{
204 		// gboolean g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info);
205 		return g_desktop_app_info_get_is_hidden(gDesktopAppInfo);
206 	}
207 	
208 	/**
209 	 * Sets the name of the desktop that the application is running in.
210 	 * This is used by g_app_info_should_show() to evaluate the
211 	 * OnlyShowIn and NotShowIn
212 	 * desktop entry fields.
213 	 * The Desktop
214 	 * Params:
215 	 * desktopEnv = a string specifying what desktop this is
216 	 */
217 	public static void setDesktopEnv(string desktopEnv)
218 	{
219 		// void g_desktop_app_info_set_desktop_env (const char *desktop_env);
220 		g_desktop_app_info_set_desktop_env(Str.toStringz(desktopEnv));
221 	}
222 }