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 gio.AppLaunchContext; 26 27 private import gio.AppInfoIF; 28 private import gio.FileIF; 29 private import gio.c.functions; 30 public import gio.c.types; 31 private import glib.ConstructionException; 32 private import glib.ListG; 33 private import glib.Str; 34 private import glib.Variant; 35 private import gobject.ObjectG; 36 private import gobject.Signals; 37 public import gtkc.giotypes; 38 private import std.algorithm; 39 40 41 /** 42 * Integrating the launch with the launching application. This is used to 43 * handle for instance startup notification and launching the new application 44 * on the same screen as the launching window. 45 */ 46 public class AppLaunchContext : ObjectG 47 { 48 /** the main Gtk struct */ 49 protected GAppLaunchContext* gAppLaunchContext; 50 51 /** Get the main Gtk struct */ 52 public GAppLaunchContext* getAppLaunchContextStruct(bool transferOwnership = false) 53 { 54 if (transferOwnership) 55 ownedRef = false; 56 return gAppLaunchContext; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)gAppLaunchContext; 63 } 64 65 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (GAppLaunchContext* gAppLaunchContext, bool ownedRef = false) 69 { 70 this.gAppLaunchContext = gAppLaunchContext; 71 super(cast(GObject*)gAppLaunchContext, ownedRef); 72 } 73 74 75 /** */ 76 public static GType getType() 77 { 78 return g_app_launch_context_get_type(); 79 } 80 81 /** 82 * Creates a new application launch context. This is not normally used, 83 * instead you instantiate a subclass of this, such as #GdkAppLaunchContext. 84 * 85 * Returns: a #GAppLaunchContext. 86 * 87 * Throws: ConstructionException GTK+ fails to create the object. 88 */ 89 public this() 90 { 91 auto p = g_app_launch_context_new(); 92 93 if(p is null) 94 { 95 throw new ConstructionException("null returned by new"); 96 } 97 98 this(cast(GAppLaunchContext*) p, true); 99 } 100 101 /** 102 * Gets the display string for the @context. This is used to ensure new 103 * applications are started on the same display as the launching 104 * application, by setting the `DISPLAY` environment variable. 105 * 106 * Params: 107 * info = a #GAppInfo 108 * files = a #GList of #GFile objects 109 * 110 * Returns: a display string for the display. 111 */ 112 public string getDisplay(AppInfoIF info, ListG files) 113 { 114 auto retStr = g_app_launch_context_get_display(gAppLaunchContext, (info is null) ? null : info.getAppInfoStruct(), (files is null) ? null : files.getListGStruct()); 115 116 scope(exit) Str.freeString(retStr); 117 return Str.toString(retStr); 118 } 119 120 /** 121 * Gets the complete environment variable list to be passed to 122 * the child process when @context is used to launch an application. 123 * This is a %NULL-terminated array of strings, where each string has 124 * the form `KEY=VALUE`. 125 * 126 * Returns: the child's environment 127 * 128 * Since: 2.32 129 */ 130 public string[] getEnvironment() 131 { 132 auto retStr = g_app_launch_context_get_environment(gAppLaunchContext); 133 134 scope(exit) Str.freeStringArray(retStr); 135 return Str.toStringArray(retStr); 136 } 137 138 /** 139 * Initiates startup notification for the application and returns the 140 * `DESKTOP_STARTUP_ID` for the launched operation, if supported. 141 * 142 * Startup notification IDs are defined in the 143 * [FreeDesktop.Org Startup Notifications standard](http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt"). 144 * 145 * Params: 146 * info = a #GAppInfo 147 * files = a #GList of of #GFile objects 148 * 149 * Returns: a startup notification ID for the application, or %NULL if 150 * not supported. 151 */ 152 public string getStartupNotifyId(AppInfoIF info, ListG files) 153 { 154 auto retStr = g_app_launch_context_get_startup_notify_id(gAppLaunchContext, (info is null) ? null : info.getAppInfoStruct(), (files is null) ? null : files.getListGStruct()); 155 156 scope(exit) Str.freeString(retStr); 157 return Str.toString(retStr); 158 } 159 160 /** 161 * Called when an application has failed to launch, so that it can cancel 162 * the application startup notification started in g_app_launch_context_get_startup_notify_id(). 163 * 164 * Params: 165 * startupNotifyId = the startup notification id that was returned by g_app_launch_context_get_startup_notify_id(). 166 */ 167 public void launchFailed(string startupNotifyId) 168 { 169 g_app_launch_context_launch_failed(gAppLaunchContext, Str.toStringz(startupNotifyId)); 170 } 171 172 /** 173 * Arranges for @variable to be set to @value in the child's 174 * environment when @context is used to launch an application. 175 * 176 * Params: 177 * variable = the environment variable to set 178 * value = the value for to set the variable to. 179 * 180 * Since: 2.32 181 */ 182 public void setenv(string variable, string value) 183 { 184 g_app_launch_context_setenv(gAppLaunchContext, Str.toStringz(variable), Str.toStringz(value)); 185 } 186 187 /** 188 * Arranges for @variable to be unset in the child's environment 189 * when @context is used to launch an application. 190 * 191 * Params: 192 * variable = the environment variable to remove 193 * 194 * Since: 2.32 195 */ 196 public void unsetenv(string variable) 197 { 198 g_app_launch_context_unsetenv(gAppLaunchContext, Str.toStringz(variable)); 199 } 200 201 /** 202 * The ::launch-failed signal is emitted when a #GAppInfo launch 203 * fails. The startup notification id is provided, so that the launcher 204 * can cancel the startup notification. 205 * 206 * Params: 207 * startupNotifyId = the startup notification id for the failed launch 208 * 209 * Since: 2.36 210 */ 211 gulong addOnLaunchFailed(void delegate(string, AppLaunchContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 212 { 213 return Signals.connect(this, "launch-failed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 214 } 215 216 /** 217 * The ::launched signal is emitted when a #GAppInfo is successfully 218 * launched. The @platform_data is an GVariant dictionary mapping 219 * strings to variants (ie a{sv}), which contains additional, 220 * platform-specific data about this launch. On UNIX, at least the 221 * "pid" and "startup-notification-id" keys will be present. 222 * 223 * Params: 224 * info = the #GAppInfo that was just launched 225 * platformData = additional platform-specific data for this launch 226 * 227 * Since: 2.36 228 */ 229 gulong addOnLaunched(void delegate(AppInfoIF, Variant, AppLaunchContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 230 { 231 return Signals.connect(this, "launched", dlg, connectFlags ^ ConnectFlags.SWAPPED); 232 } 233 }