| 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 = GAppInfo.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = AppInfoT |
|---|
| 29 |
* strct = GAppInfo |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = AppInfoT |
|---|
| 33 |
* interf = AppInfoIF |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* - TStruct |
|---|
| 38 |
* extend = |
|---|
| 39 |
* implements: |
|---|
| 40 |
* prefixes: |
|---|
| 41 |
* - g_app_info_ |
|---|
| 42 |
* omit structs: |
|---|
| 43 |
* omit prefixes: |
|---|
| 44 |
* - g_app_launch_context_ |
|---|
| 45 |
* omit code: |
|---|
| 46 |
* omit signals: |
|---|
| 47 |
* imports: |
|---|
| 48 |
* - glib.Str |
|---|
| 49 |
* - glib.ErrorG |
|---|
| 50 |
* - glib.GException |
|---|
| 51 |
* - glib.ListG |
|---|
| 52 |
* - gio.AppInfoIF |
|---|
| 53 |
* - gio.AppLaunchContext |
|---|
| 54 |
* - gio.Icon |
|---|
| 55 |
* - gio.IconIF |
|---|
| 56 |
* structWrap: |
|---|
| 57 |
* - GAppInfo* -> AppInfoIF |
|---|
| 58 |
* - GAppLaunchContext* -> AppLaunchContext |
|---|
| 59 |
* - GIcon* -> IconIF |
|---|
| 60 |
* - GList* -> ListG |
|---|
| 61 |
* module aliases: |
|---|
| 62 |
* local aliases: |
|---|
| 63 |
* overrides: |
|---|
| 64 |
*/ |
|---|
| 65 |
|
|---|
| 66 |
module gio.AppInfoT; |
|---|
| 67 |
|
|---|
| 68 |
public import gtkc.giotypes; |
|---|
| 69 |
|
|---|
| 70 |
public import gtkc.gio; |
|---|
| 71 |
public import glib.ConstructionException; |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
public import glib.Str; |
|---|
| 75 |
public import glib.ErrorG; |
|---|
| 76 |
public import glib.GException; |
|---|
| 77 |
public import glib.ListG; |
|---|
| 78 |
public import gio.AppInfoIF; |
|---|
| 79 |
public import gio.AppLaunchContext; |
|---|
| 80 |
public import gio.Icon; |
|---|
| 81 |
public import gio.IconIF; |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
/** |
|---|
| 87 |
* Description |
|---|
| 88 |
* GAppInfo and GAppLaunchContext are used for describing and launching |
|---|
| 89 |
* applications installed on the system. |
|---|
| 90 |
* As of GLib 2.20, URIs will always be converted to POSIX paths |
|---|
| 91 |
* (using g_file_get_path()) when using g_app_info_launch() even if |
|---|
| 92 |
* the application requested an URI and not a POSIX path. For example |
|---|
| 93 |
* for an desktop-file based application with Exec key totem |
|---|
| 94 |
* %U and a single URI, |
|---|
| 95 |
* sftp://foo/file.avi, then |
|---|
| 96 |
* /home/user/.gvfs/sftp on foo/file.avi will be |
|---|
| 97 |
* passed. This will only work if a set of suitable GIO extensions |
|---|
| 98 |
* (such as gvfs 2.26 compiled with FUSE support), is available and |
|---|
| 99 |
* operational; if this is not the case, the URI will be passed |
|---|
| 100 |
* unmodified to the application. Some URIs, such as |
|---|
| 101 |
* mailto:, of course cannot be mapped to a POSIX |
|---|
| 102 |
* path (in gvfs there's no FUSE mount for it); such URIs will be |
|---|
| 103 |
* passed unmodified to the application. |
|---|
| 104 |
* Specifically for gvfs 2.26 and later, the POSIX URI will be mapped |
|---|
| 105 |
* back to the GIO URI in the GFile constructors (since gvfs |
|---|
| 106 |
* implements the GVfs extension point). As such, if the application |
|---|
| 107 |
* needs to examine the URI, it needs to use g_file_get_uri() or |
|---|
| 108 |
* similar on GFile. In other words, an application cannot assume |
|---|
| 109 |
* that the URI passed to e.g. g_file_new_for_commandline_arg() is |
|---|
| 110 |
* equal to the result of g_file_get_uri(). The following snippet |
|---|
| 111 |
* illustrates this: |
|---|
| 112 |
* GFile *f; |
|---|
| 113 |
* char *uri; |
|---|
| 114 |
* file = g_file_new_for_commandline_arg (uri_from_commandline); |
|---|
| 115 |
* uri = g_file_get_uri (file); |
|---|
| 116 |
* strcmp (uri, uri_from_commandline) == 0; // FALSE |
|---|
| 117 |
* g_free (uri); |
|---|
| 118 |
* if (g_file_has_uri_scheme (file, "cdda")) |
|---|
| 119 |
* { |
|---|
| 120 |
* // do something special with uri |
|---|
| 121 |
* } |
|---|
| 122 |
* g_object_unref (file); |
|---|
| 123 |
* This code will work when both cdda://sr0/Track |
|---|
| 124 |
* 1.wav and /home/user/.gvfs/cdda on sr0/Track |
|---|
| 125 |
* 1.wav is passed to the application. It should be noted |
|---|
| 126 |
* that it's generally not safe for applications to rely on the format |
|---|
| 127 |
* of a particular URIs. Different launcher applications (e.g. file |
|---|
| 128 |
* managers) may have different ideas of what a given URI means. |
|---|
| 129 |
*/ |
|---|
| 130 |
public template AppInfoT(TStruct) |
|---|
| 131 |
{ |
|---|
| 132 |
|
|---|
| 133 |
/** the main Gtk struct */ |
|---|
| 134 |
protected GAppInfo* gAppInfo; |
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
public GAppInfo* getAppInfoTStruct() |
|---|
| 138 |
{ |
|---|
| 139 |
return cast(GAppInfo*)getStruct(); |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
/** |
|---|
| 144 |
*/ |
|---|
| 145 |
|
|---|
| 146 |
/** |
|---|
| 147 |
* Creates a new GAppInfo from the given information. |
|---|
| 148 |
* Params: |
|---|
| 149 |
* commandline = the commandline to use |
|---|
| 150 |
* applicationName = the application name, or NULL to use commandline. [allow-none] |
|---|
| 151 |
* flags = flags that can specify details of the created GAppInfo |
|---|
| 152 |
* Returns: new GAppInfo for given command. [transfer full] |
|---|
| 153 |
* Throws: GException on failure. |
|---|
| 154 |
*/ |
|---|
| 155 |
public static AppInfoIF createFromCommandline(string commandline, string applicationName, GAppInfoCreateFlags flags) |
|---|
| 156 |
{ |
|---|
| 157 |
// GAppInfo * g_app_info_create_from_commandline (const char *commandline, const char *application_name, GAppInfoCreateFlags flags, GError **error); |
|---|
| 158 |
GError* err = null; |
|---|
| 159 |
|
|---|
| 160 |
auto p = g_app_info_create_from_commandline(Str.toStringz(commandline), Str.toStringz(applicationName), flags, &err); |
|---|
| 161 |
|
|---|
| 162 |
if (err !is null) |
|---|
| 163 |
{ |
|---|
| 164 |
throw new GException( new ErrorG(err) ); |
|---|
| 165 |
} |
|---|
| 166 |
|
|---|
| 167 |
if(p is null) |
|---|
| 168 |
{ |
|---|
| 169 |
return null; |
|---|
| 170 |
} |
|---|
| 171 |
return new AppInfo(cast(GAppInfo*) p); |
|---|
| 172 |
} |
|---|
| 173 |
|
|---|
| 174 |
/** |
|---|
| 175 |
* Creates a duplicate of a GAppInfo. |
|---|
| 176 |
* Returns: a duplicate of appinfo. [transfer full] |
|---|
| 177 |
*/ |
|---|
| 178 |
public AppInfoIF dup() |
|---|
| 179 |
{ |
|---|
| 180 |
// GAppInfo * g_app_info_dup (GAppInfo *appinfo); |
|---|
| 181 |
auto p = g_app_info_dup(getAppInfoTStruct()); |
|---|
| 182 |
if(p is null) |
|---|
| 183 |
{ |
|---|
| 184 |
return null; |
|---|
| 185 |
} |
|---|
| 186 |
return new AppInfo(cast(GAppInfo*) p); |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
/** |
|---|
| 190 |
* Checks if two GAppInfos are equal. |
|---|
| 191 |
* Params: |
|---|
| 192 |
* appinfo2 = the second GAppInfo. |
|---|
| 193 |
* Returns: TRUE if appinfo1 is equal to appinfo2. FALSE otherwise. |
|---|
| 194 |
*/ |
|---|
| 195 |
public int equal(AppInfoIF appinfo2) |
|---|
| 196 |
{ |
|---|
| 197 |
// gboolean g_app_info_equal (GAppInfo *appinfo1, GAppInfo *appinfo2); |
|---|
| 198 |
return g_app_info_equal(getAppInfoTStruct(), (appinfo2 is null) ? null : appinfo2.getAppInfoTStruct()); |
|---|
| 199 |
} |
|---|
| 200 |
|
|---|
| 201 |
/** |
|---|
| 202 |
* Gets the ID of an application. An id is a string that |
|---|
| 203 |
* identifies the application. The exact format of the id is |
|---|
| 204 |
* platform dependent. For instance, on Unix this is the |
|---|
| 205 |
* desktop file id from the xdg menu specification. |
|---|
| 206 |
* Note that the returned ID may be NULL, depending on how |
|---|
| 207 |
* the appinfo has been constructed. |
|---|
| 208 |
* Returns: a string containing the application's ID. |
|---|
| 209 |
*/ |
|---|
| 210 |
public string getId() |
|---|
| 211 |
{ |
|---|
| 212 |
// const char * g_app_info_get_id (GAppInfo *appinfo); |
|---|
| 213 |
return Str.toString(g_app_info_get_id(getAppInfoTStruct())); |
|---|
| 214 |
} |
|---|
| 215 |
|
|---|
| 216 |
/** |
|---|
| 217 |
* Gets the installed name of the application. |
|---|
| 218 |
* Returns: the name of the application for appinfo. |
|---|
| 219 |
*/ |
|---|
| 220 |
public string getName() |
|---|
| 221 |
{ |
|---|
| 222 |
// const char * g_app_info_get_name (GAppInfo *appinfo); |
|---|
| 223 |
return Str.toString(g_app_info_get_name(getAppInfoTStruct())); |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
/** |
|---|
| 227 |
* Gets the display name of the application. The display name is often more |
|---|
| 228 |
* descriptive to the user than the name itself. |
|---|
| 229 |
* Since 2.24 |
|---|
| 230 |
* Returns: the display name of the application for appinfo, or the name if no display name is available. |
|---|
| 231 |
*/ |
|---|
| 232 |
public string getDisplayName() |
|---|
| 233 |
{ |
|---|
| 234 |
// const char * g_app_info_get_display_name (GAppInfo *appinfo); |
|---|
| 235 |
return Str.toString(g_app_info_get_display_name(getAppInfoTStruct())); |
|---|
| 236 |
} |
|---|
| 237 |
|
|---|
| 238 |
/** |
|---|
| 239 |
* Gets a human-readable description of an installed application. |
|---|
| 240 |
* Returns: a string containing a description of the application appinfo, or NULL if none. |
|---|
| 241 |
*/ |
|---|
| 242 |
public string getDescription() |
|---|
| 243 |
{ |
|---|
| 244 |
// const char * g_app_info_get_description (GAppInfo *appinfo); |
|---|
| 245 |
return Str.toString(g_app_info_get_description(getAppInfoTStruct())); |
|---|
| 246 |
} |
|---|
| 247 |
|
|---|
| 248 |
/** |
|---|
| 249 |
* Gets the executable's name for the installed application. |
|---|
| 250 |
* Returns: a string containing the appinfo's application binaries name |
|---|
| 251 |
*/ |
|---|
| 252 |
public string getExecutable() |
|---|
| 253 |
{ |
|---|
| 254 |
// const char * g_app_info_get_executable (GAppInfo *appinfo); |
|---|
| 255 |
return Str.toString(g_app_info_get_executable(getAppInfoTStruct())); |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
/** |
|---|
| 259 |
* Gets the commandline with which the application will be |
|---|
| 260 |
* started. |
|---|
| 261 |
* Since 2.20 |
|---|
| 262 |
* Returns: a string containing the appinfo's commandline, or NULL if this information is not available |
|---|
| 263 |
*/ |
|---|
| 264 |
public string getCommandline() |
|---|
| 265 |
{ |
|---|
| 266 |
// const char * g_app_info_get_commandline (GAppInfo *appinfo); |
|---|
| 267 |
return Str.toString(g_app_info_get_commandline(getAppInfoTStruct())); |
|---|
| 268 |
} |
|---|
| 269 |
|
|---|
| 270 |
/** |
|---|
| 271 |
* Gets the icon for the application. |
|---|
| 272 |
* Returns: the default GIcon for appinfo. [transfer none] |
|---|
| 273 |
*/ |
|---|
| 274 |
public IconIF getIcon() |
|---|
| 275 |
{ |
|---|
| 276 |
// GIcon * g_app_info_get_icon (GAppInfo *appinfo); |
|---|
| 277 |
auto p = g_app_info_get_icon(getAppInfoTStruct()); |
|---|
| 278 |
if(p is null) |
|---|
| 279 |
{ |
|---|
| 280 |
return null; |
|---|
| 281 |
} |
|---|
| 282 |
return new Icon(cast(GIcon*) p); |
|---|
| 283 |
} |
|---|
| 284 |
|
|---|
| 285 |
/** |
|---|
| 286 |
* Launches the application. Passes files to the launched application |
|---|
| 287 |
* as arguments, using the optional launch_context to get information |
|---|
| 288 |
* about the details of the launcher (like what screen it is on). |
|---|
| 289 |
* On error, error will be set accordingly. |
|---|
| 290 |
* To launch the application without arguments pass a NULL files list. |
|---|
| 291 |
* Note that even if the launch is successful the application launched |
|---|
| 292 |
* can fail to start if it runs into problems during startup. There is |
|---|
| 293 |
* no way to detect this. |
|---|
| 294 |
* Some URIs can be changed when passed through a GFile (for instance |
|---|
| 295 |
* unsupported uris with strange formats like mailto:), so if you have |
|---|
| 296 |
* a textual uri you want to pass in as argument, consider using |
|---|
| 297 |
* g_app_info_launch_uris() instead. |
|---|
| 298 |
* On UNIX, this function sets the GIO_LAUNCHED_DESKTOP_FILE |
|---|
| 299 |
* environment variable with the path of the launched desktop file and |
|---|
| 300 |
* GIO_LAUNCHED_DESKTOP_FILE_PID to the process |
|---|
| 301 |
* id of the launched process. This can be used to ignore |
|---|
| 302 |
* GIO_LAUNCHED_DESKTOP_FILE, should it be inherited |
|---|
| 303 |
* by further processes. The DISPLAY and |
|---|
| 304 |
* DESKTOP_STARTUP_ID environment variables are also |
|---|
| 305 |
* set, based on information provided in launch_context. |
|---|
| 306 |
* Params: |
|---|
| 307 |
* files = a GList of GFile objects. [element-type GFile] |
|---|
| 308 |
* launchContext = a GAppLaunchContext or NULL. [allow-none] |
|---|
| 309 |
* Returns: TRUE on successful launch, FALSE otherwise. |
|---|
| 310 |
* Throws: GException on failure. |
|---|
| 311 |
*/ |
|---|
| 312 |
public int launch(ListG files, AppLaunchContext launchContext) |
|---|
| 313 |
{ |
|---|
| 314 |
// gboolean g_app_info_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error); |
|---|
| 315 |
GError* err = null; |
|---|
| 316 |
|
|---|
| 317 |
auto p = g_app_info_launch(getAppInfoTStruct(), (files is null) ? null : files.getListGStruct(), (launchContext is null) ? null : launchContext.getAppLaunchContextStruct(), &err); |
|---|
| 318 |
|
|---|
| 319 |
if (err !is null) |
|---|
| 320 |
{ |
|---|
| 321 |
throw new GException( new ErrorG(err) ); |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
return p; |
|---|
| 325 |
} |
|---|
| 326 |
|
|---|
| 327 |
/** |
|---|
| 328 |
* Checks if the application accepts files as arguments. |
|---|
| 329 |
* Returns: TRUE if the appinfo supports files. |
|---|
| 330 |
*/ |
|---|
| 331 |
public int supportsFiles() |
|---|
| 332 |
{ |
|---|
| 333 |
// gboolean g_app_info_supports_files (GAppInfo *appinfo); |
|---|
| 334 |
return g_app_info_supports_files(getAppInfoTStruct()); |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
/** |
|---|
| 338 |
* Checks if the application supports reading files and directories from URIs. |
|---|
| 339 |
* Returns: TRUE if the appinfo supports URIs. |
|---|
| 340 |
*/ |
|---|
| 341 |
public int supportsUris() |
|---|
| 342 |
{ |
|---|
| 343 |
// gboolean g_app_info_supports_uris (GAppInfo *appinfo); |
|---|
| 344 |
return g_app_info_supports_uris(getAppInfoTStruct()); |
|---|
| 345 |
} |
|---|
| 346 |
|
|---|
| 347 |
/** |
|---|
| 348 |
* Launches the application. Passes uris to the launched application |
|---|
| 349 |
* as arguments, using the optional launch_context to get information |
|---|
| 350 |
* about the details of the launcher (like what screen it is on). |
|---|
| 351 |
* On error, error will be set accordingly. |
|---|
| 352 |
* To lauch the application without arguments pass a NULL uris list. |
|---|
| 353 |
* Note that even if the launch is successful the application launched |
|---|
| 354 |
* can fail to start if it runs into problems during startup. There is |
|---|
| 355 |
* no way to detect this. |
|---|
| 356 |
* Params: |
|---|
| 357 |
* uris = a GList containing URIs to launch. [element-type utf8] |
|---|
| 358 |
* launchContext = a GAppLaunchContext or NULL. [allow-none] |
|---|
| 359 |
* Returns: TRUE on successful launch, FALSE otherwise. |
|---|
| 360 |
* Throws: GException on failure. |
|---|
| 361 |
*/ |
|---|
| 362 |
public int launchUris(ListG uris, AppLaunchContext launchContext) |
|---|
| 363 |
{ |
|---|
| 364 |
// gboolean g_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GAppLaunchContext *launch_context, GError **error); |
|---|
| 365 |
GError* err = null; |
|---|
| 366 |
|
|---|
| 367 |
auto p = g_app_info_launch_uris(getAppInfoTStruct(), (uris is null) ? null : uris.getListGStruct(), (launchContext is null) ? null : launchContext.getAppLaunchContextStruct(), &err); |
|---|
| 368 |
|
|---|
| 369 |
if (err !is null) |
|---|
| 370 |
{ |
|---|
| 371 |
throw new GException( new ErrorG(err) ); |
|---|
| 372 |
} |
|---|
| 373 |
|
|---|
| 374 |
return p; |
|---|
| 375 |
} |
|---|
| 376 |
|
|---|
| 377 |
/** |
|---|
| 378 |
* Checks if the application info should be shown in menus that |
|---|
| 379 |
* list available applications. |
|---|
| 380 |
* Returns: TRUE if the appinfo should be shown, FALSE otherwise. |
|---|
| 381 |
*/ |
|---|
| 382 |
public int shouldShow() |
|---|
| 383 |
{ |
|---|
| 384 |
// gboolean g_app_info_should_show (GAppInfo *appinfo); |
|---|
| 385 |
return g_app_info_should_show(getAppInfoTStruct()); |
|---|
| 386 |
} |
|---|
| 387 |
|
|---|
| 388 |
/** |
|---|
| 389 |
* Obtains the information whether the GAppInfo can be deleted. |
|---|
| 390 |
* See g_app_info_delete(). |
|---|
| 391 |
* Since 2.20 |
|---|
| 392 |
* Returns: TRUE if appinfo can be deleted |
|---|
| 393 |
*/ |
|---|
| 394 |
public int canDelete() |
|---|
| 395 |
{ |
|---|
| 396 |
// gboolean g_app_info_can_delete (GAppInfo *appinfo); |
|---|
| 397 |
return g_app_info_can_delete(getAppInfoTStruct()); |
|---|
| 398 |
} |
|---|
| 399 |
|
|---|
| 400 |
/** |
|---|
| 401 |
* Tries to delete a GAppInfo. |
|---|
| 402 |
* On some platforms, there may be a difference between user-defined |
|---|
| 403 |
* GAppInfos which can be deleted, and system-wide ones which |
|---|
| 404 |
* cannot. See g_app_info_can_delete(). |
|---|
| 405 |
* Virtual: do_delete |
|---|
| 406 |
* Since 2.20 |
|---|
| 407 |
* Returns: TRUE if appinfo has been deleted |
|---|
| 408 |
*/ |
|---|
| 409 |
public int delet() |
|---|
| 410 |
{ |
|---|
| 411 |
// gboolean g_app_info_delete (GAppInfo *appinfo); |
|---|
| 412 |
return g_app_info_delete(getAppInfoTStruct()); |
|---|
| 413 |
} |
|---|
| 414 |
|
|---|
| 415 |
/** |
|---|
| 416 |
* Removes all changes to the type associations done by |
|---|
| 417 |
* g_app_info_set_as_default_for_type(), |
|---|
| 418 |
* g_app_info_set_as_default_for_extension(), |
|---|
| 419 |
* g_app_info_add_supports_type() or g_app_info_remove_supports_type(). |
|---|
| 420 |
* Since 2.20 |
|---|
| 421 |
* Params: |
|---|
| 422 |
* contentType = a content type |
|---|
| 423 |
*/ |
|---|
| 424 |
public static void resetTypeAssociations(string contentType) |
|---|
| 425 |
{ |
|---|
| 426 |
// void g_app_info_reset_type_associations (const char *content_type); |
|---|
| 427 |
g_app_info_reset_type_associations(Str.toStringz(contentType)); |
|---|
| 428 |
} |
|---|
| 429 |
|
|---|
| 430 |
/** |
|---|
| 431 |
* Sets the application as the default handler for a given type. |
|---|
| 432 |
* Params: |
|---|
| 433 |
* contentType = the content type. |
|---|
| 434 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 435 |
* Throws: GException on failure. |
|---|
| 436 |
*/ |
|---|
| 437 |
public int setAsDefaultForType(string contentType) |
|---|
| 438 |
{ |
|---|
| 439 |
// gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo, const char *content_type, GError **error); |
|---|
| 440 |
GError* err = null; |
|---|
| 441 |
|
|---|
| 442 |
auto p = g_app_info_set_as_default_for_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); |
|---|
| 443 |
|
|---|
| 444 |
if (err !is null) |
|---|
| 445 |
{ |
|---|
| 446 |
throw new GException( new ErrorG(err) ); |
|---|
| 447 |
} |
|---|
| 448 |
|
|---|
| 449 |
return p; |
|---|
| 450 |
} |
|---|
| 451 |
|
|---|
| 452 |
/** |
|---|
| 453 |
* Sets the application as the default handler for the given file extension. |
|---|
| 454 |
* Params: |
|---|
| 455 |
* extension = a string containing the file extension (without the dot). |
|---|
| 456 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 457 |
* Throws: GException on failure. |
|---|
| 458 |
*/ |
|---|
| 459 |
public int setAsDefaultForExtension(string extension) |
|---|
| 460 |
{ |
|---|
| 461 |
// gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo, const char *extension, GError **error); |
|---|
| 462 |
GError* err = null; |
|---|
| 463 |
|
|---|
| 464 |
auto p = g_app_info_set_as_default_for_extension(getAppInfoTStruct(), Str.toStringz(extension), &err); |
|---|
| 465 |
|
|---|
| 466 |
if (err !is null) |
|---|
| 467 |
{ |
|---|
| 468 |
throw new GException( new ErrorG(err) ); |
|---|
| 469 |
} |
|---|
| 470 |
|
|---|
| 471 |
return p; |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
/** |
|---|
| 475 |
* Sets the application as the last used application for a given type. |
|---|
| 476 |
* This will make the application appear as first in the list returned by |
|---|
| 477 |
* g_app_info_get_recommended_for_type, regardless of the default application |
|---|
| 478 |
* for that content type. |
|---|
| 479 |
* Params: |
|---|
| 480 |
* contentType = the content type. |
|---|
| 481 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 482 |
* Throws: GException on failure. |
|---|
| 483 |
*/ |
|---|
| 484 |
public int setAsLastUsedForType(string contentType) |
|---|
| 485 |
{ |
|---|
| 486 |
// gboolean g_app_info_set_as_last_used_for_type (GAppInfo *appinfo, const char *content_type, GError **error); |
|---|
| 487 |
GError* err = null; |
|---|
| 488 |
|
|---|
| 489 |
auto p = g_app_info_set_as_last_used_for_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); |
|---|
| 490 |
|
|---|
| 491 |
if (err !is null) |
|---|
| 492 |
{ |
|---|
| 493 |
throw new GException( new ErrorG(err) ); |
|---|
| 494 |
} |
|---|
| 495 |
|
|---|
| 496 |
return p; |
|---|
| 497 |
} |
|---|
| 498 |
|
|---|
| 499 |
/** |
|---|
| 500 |
* Adds a content type to the application information to indicate the |
|---|
| 501 |
* application is capable of opening files with the given content type. |
|---|
| 502 |
* Params: |
|---|
| 503 |
* contentType = a string. |
|---|
| 504 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 505 |
* Throws: GException on failure. |
|---|
| 506 |
*/ |
|---|
| 507 |
public int addSupportsType(string contentType) |
|---|
| 508 |
{ |
|---|
| 509 |
// gboolean g_app_info_add_supports_type (GAppInfo *appinfo, const char *content_type, GError **error); |
|---|
| 510 |
GError* err = null; |
|---|
| 511 |
|
|---|
| 512 |
auto p = g_app_info_add_supports_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); |
|---|
| 513 |
|
|---|
| 514 |
if (err !is null) |
|---|
| 515 |
{ |
|---|
| 516 |
throw new GException( new ErrorG(err) ); |
|---|
| 517 |
} |
|---|
| 518 |
|
|---|
| 519 |
return p; |
|---|
| 520 |
} |
|---|
| 521 |
|
|---|
| 522 |
/** |
|---|
| 523 |
* Checks if a supported content type can be removed from an application. |
|---|
| 524 |
* Returns: TRUE if it is possible to remove supported content types from a given appinfo, FALSE if not. |
|---|
| 525 |
*/ |
|---|
| 526 |
public int canRemoveSupportsType() |
|---|
| 527 |
{ |
|---|
| 528 |
// gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo); |
|---|
| 529 |
return g_app_info_can_remove_supports_type(getAppInfoTStruct()); |
|---|
| 530 |
} |
|---|
| 531 |
|
|---|
| 532 |
/** |
|---|
| 533 |
* Removes a supported type from an application, if possible. |
|---|
| 534 |
* Params: |
|---|
| 535 |
* contentType = a string. |
|---|
| 536 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 537 |
* Throws: GException on failure. |
|---|
| 538 |
*/ |
|---|
| 539 |
public int removeSupportsType(string contentType) |
|---|
| 540 |
{ |
|---|
| 541 |
// gboolean g_app_info_remove_supports_type (GAppInfo *appinfo, const char *content_type, GError **error); |
|---|
| 542 |
GError* err = null; |
|---|
| 543 |
|
|---|
| 544 |
auto p = g_app_info_remove_supports_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); |
|---|
| 545 |
|
|---|
| 546 |
if (err !is null) |
|---|
| 547 |
{ |
|---|
| 548 |
throw new GException( new ErrorG(err) ); |
|---|
| 549 |
} |
|---|
| 550 |
|
|---|
| 551 |
return p; |
|---|
| 552 |
} |
|---|
| 553 |
|
|---|
| 554 |
/** |
|---|
| 555 |
* Gets a list of all of the applications currently registered |
|---|
| 556 |
* on this system. |
|---|
| 557 |
* For desktop files, this includes applications that have |
|---|
| 558 |
* NoDisplay=true set or are excluded from |
|---|
| 559 |
* display by means of OnlyShowIn or |
|---|
| 560 |
* NotShowIn. See g_app_info_should_show(). |
|---|
| 561 |
* The returned list does not include applications which have |
|---|
| 562 |
* the Hidden key set. |
|---|
| 563 |
* Returns: a newly allocated GList of references to GAppInfos. [element-type GAppInfo][transfer full] |
|---|
| 564 |
*/ |
|---|
| 565 |
public static ListG getAll() |
|---|
| 566 |
{ |
|---|
| 567 |
// GList * g_app_info_get_all (void); |
|---|
| 568 |
auto p = g_app_info_get_all(); |
|---|
| 569 |
if(p is null) |
|---|
| 570 |
{ |
|---|
| 571 |
return null; |
|---|
| 572 |
} |
|---|
| 573 |
return new ListG(cast(GList*) p); |
|---|
| 574 |
} |
|---|
| 575 |
|
|---|
| 576 |
/** |
|---|
| 577 |
* Gets a list of all GAppInfos for a given content type. |
|---|
| 578 |
* Params: |
|---|
| 579 |
* contentType = the content type to find a GAppInfo for |
|---|
| 580 |
* Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] |
|---|
| 581 |
*/ |
|---|
| 582 |
public static ListG getAllForType(string contentType) |
|---|
| 583 |
{ |
|---|
| 584 |
// GList * g_app_info_get_all_for_type (const char *content_type); |
|---|
| 585 |
auto p = g_app_info_get_all_for_type(Str.toStringz(contentType)); |
|---|
| 586 |
if(p is null) |
|---|
| 587 |
{ |
|---|
| 588 |
return null; |
|---|
| 589 |
} |
|---|
| 590 |
return new ListG(cast(GList*) p); |
|---|
| 591 |
} |
|---|
| 592 |
|
|---|
| 593 |
/** |
|---|
| 594 |
* Gets the GAppInfo that corresponds to a given content type. |
|---|
| 595 |
* Params: |
|---|
| 596 |
* contentType = the content type to find a GAppInfo for |
|---|
| 597 |
* mustSupportUris = if TRUE, the GAppInfo is expected to |
|---|
| 598 |
* support URIs |
|---|
| 599 |
* Returns: GAppInfo for given content_type or NULL on error. [transfer full] |
|---|
| 600 |
*/ |
|---|
| 601 |
public static AppInfoIF getDefaultForType(string contentType, int mustSupportUris) |
|---|
| 602 |
{ |
|---|
| 603 |
// GAppInfo * g_app_info_get_default_for_type (const char *content_type, gboolean must_support_uris); |
|---|
| 604 |
auto p = g_app_info_get_default_for_type(Str.toStringz(contentType), mustSupportUris); |
|---|
| 605 |
if(p is null) |
|---|
| 606 |
{ |
|---|
| 607 |
return null; |
|---|
| 608 |
} |
|---|
| 609 |
return new AppInfo(cast(GAppInfo*) p); |
|---|
| 610 |
} |
|---|
| 611 |
|
|---|
| 612 |
/** |
|---|
| 613 |
* Gets the default application for launching applications |
|---|
| 614 |
* using this URI scheme. A URI scheme is the initial part |
|---|
| 615 |
* of the URI, up to but not including the ':', e.g. "http", |
|---|
| 616 |
* "ftp" or "sip". |
|---|
| 617 |
* Params: |
|---|
| 618 |
* uriScheme = a string containing a URI scheme. |
|---|
| 619 |
* Returns: GAppInfo for given uri_scheme or NULL on error. [transfer full] |
|---|
| 620 |
*/ |
|---|
| 621 |
public static AppInfoIF getDefaultForUriScheme(string uriScheme) |
|---|
| 622 |
{ |
|---|
| 623 |
// GAppInfo * g_app_info_get_default_for_uri_scheme (const char *uri_scheme); |
|---|
| 624 |
auto p = g_app_info_get_default_for_uri_scheme(Str.toStringz(uriScheme)); |
|---|
| 625 |
if(p is null) |
|---|
| 626 |
{ |
|---|
| 627 |
return null; |
|---|
| 628 |
} |
|---|
| 629 |
return new AppInfo(cast(GAppInfo*) p); |
|---|
| 630 |
} |
|---|
| 631 |
|
|---|
| 632 |
/** |
|---|
| 633 |
* Gets a list of fallback GAppInfos for a given content type, i.e. |
|---|
| 634 |
* those applications which claim to support the given content type |
|---|
| 635 |
* by MIME type subclassing and not directly. |
|---|
| 636 |
* Since 2.28 |
|---|
| 637 |
* Params: |
|---|
| 638 |
* contentType = the content type to find a GAppInfo for |
|---|
| 639 |
* Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] |
|---|
| 640 |
*/ |
|---|
| 641 |
public static ListG getFallbackForType(string contentType) |
|---|
| 642 |
{ |
|---|
| 643 |
// GList * g_app_info_get_fallback_for_type (const gchar *content_type); |
|---|
| 644 |
auto p = g_app_info_get_fallback_for_type(Str.toStringz(contentType)); |
|---|
| 645 |
if(p is null) |
|---|
| 646 |
{ |
|---|
| 647 |
return null; |
|---|
| 648 |
} |
|---|
| 649 |
return new ListG(cast(GList*) p); |
|---|
| 650 |
} |
|---|
| 651 |
|
|---|
| 652 |
/** |
|---|
| 653 |
* Gets a list of recommended GAppInfos for a given content type, i.e. |
|---|
| 654 |
* those applications which claim to support the given content type exactly, |
|---|
| 655 |
* and not by MIME type subclassing. |
|---|
| 656 |
* Note that the first application of the list is the last used one, i.e. |
|---|
| 657 |
* the last one for which g_app_info_set_as_last_used_for_type has been |
|---|
| 658 |
* called. |
|---|
| 659 |
* Since 2.28 |
|---|
| 660 |
* Params: |
|---|
| 661 |
* contentType = the content type to find a GAppInfo for |
|---|
| 662 |
* Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] |
|---|
| 663 |
*/ |
|---|
| 664 |
public static ListG getRecommendedForType(string contentType) |
|---|
| 665 |
{ |
|---|
| 666 |
// GList * g_app_info_get_recommended_for_type (const gchar *content_type); |
|---|
| 667 |
auto p = g_app_info_get_recommended_for_type(Str.toStringz(contentType)); |
|---|
| 668 |
if(p is null) |
|---|
| 669 |
{ |
|---|
| 670 |
return null; |
|---|
| 671 |
} |
|---|
| 672 |
return new ListG(cast(GList*) p); |
|---|
| 673 |
} |
|---|
| 674 |
|
|---|
| 675 |
/** |
|---|
| 676 |
* Utility function that launches the default application |
|---|
| 677 |
* registered to handle the specified uri. Synchronous I/O |
|---|
| 678 |
* is done on the uri to detect the type of the file if |
|---|
| 679 |
* required. |
|---|
| 680 |
* Params: |
|---|
| 681 |
* uri = the uri to show |
|---|
| 682 |
* launchContext = an optional GAppLaunchContext. [allow-none] |
|---|
| 683 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 684 |
* Throws: GException on failure. |
|---|
| 685 |
*/ |
|---|
| 686 |
public static int launchDefaultForUri(string uri, AppLaunchContext launchContext) |
|---|
| 687 |
{ |
|---|
| 688 |
// gboolean g_app_info_launch_default_for_uri (const char *uri, GAppLaunchContext *launch_context, GError **error); |
|---|
| 689 |
GError* err = null; |
|---|
| 690 |
|
|---|
| 691 |
auto p = g_app_info_launch_default_for_uri(Str.toStringz(uri), (launchContext is null) ? null : launchContext.getAppLaunchContextStruct(), &err); |
|---|
| 692 |
|
|---|
| 693 |
if (err !is null) |
|---|
| 694 |
{ |
|---|
| 695 |
throw new GException( new ErrorG(err) ); |
|---|
| 696 |
} |
|---|
| 697 |
|
|---|
| 698 |
return p; |
|---|
| 699 |
} |
|---|
| 700 |
} |
|---|