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 = GMountOperation.html 27 * outPack = gio 28 * outFile = MountOperation 29 * strct = GMountOperation 30 * realStrct= 31 * ctorStrct= 32 * clss = MountOperation 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = GObject 38 * implements: 39 * prefixes: 40 * - g_mount_operation_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ArrayG 48 * structWrap: 49 * - GArray* -> ArrayG 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module gio.MountOperation; 56 57 public import gtkc.giotypes; 58 59 private import gtkc.gio; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import gobject.Signals; 64 public import gtkc.gdktypes; 65 private import glib.Str; 66 private import glib.ArrayG; 67 68 69 private import gobject.ObjectG; 70 71 /** 72 * GMountOperation provides a mechanism for interacting with the user. 73 * It can be used for authenticating mountable operations, such as loop 74 * mounting files, hard drive partitions or server locations. It can 75 * also be used to ask the user questions or show a list of applications 76 * preventing unmount or eject operations from completing. 77 * 78 * Note that GMountOperation is used for more than just GMount 79 * objects – for example it is also used in g_drive_start() and 80 * g_drive_stop(). 81 * 82 * Users should instantiate a subclass of this that implements all the 83 * various callbacks to show the required dialogs, such as 84 * GtkMountOperation. If no user interaction is desired (for example 85 * when automounting filesystems at login time), usually NULL can be 86 * passed, see each method taking a GMountOperation for details. 87 */ 88 public class MountOperation : ObjectG 89 { 90 91 /** the main Gtk struct */ 92 protected GMountOperation* gMountOperation; 93 94 95 /** Get the main Gtk struct */ 96 public GMountOperation* getMountOperationStruct() 97 { 98 return gMountOperation; 99 } 100 101 102 /** the main Gtk struct as a void* */ 103 protected override void* getStruct() 104 { 105 return cast(void*)gMountOperation; 106 } 107 108 /** 109 * Sets our main struct and passes it to the parent class 110 */ 111 public this (GMountOperation* gMountOperation) 112 { 113 super(cast(GObject*)gMountOperation); 114 this.gMountOperation = gMountOperation; 115 } 116 117 protected override void setStruct(GObject* obj) 118 { 119 super.setStruct(obj); 120 gMountOperation = cast(GMountOperation*)obj; 121 } 122 123 /** 124 */ 125 int[string] connectedSignals; 126 127 void delegate(MountOperation)[] onAbortedListeners; 128 /** 129 * Emitted by the backend when e.g. a device becomes unavailable 130 * while a mount operation is in progress. 131 * Implementations of GMountOperation should handle this signal 132 * by dismissing open password dialogs. 133 * Since 2.20 134 */ 135 void addOnAborted(void delegate(MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 136 { 137 if ( !("aborted" in connectedSignals) ) 138 { 139 Signals.connectData( 140 getStruct(), 141 "aborted", 142 cast(GCallback)&callBackAborted, 143 cast(void*)this, 144 null, 145 connectFlags); 146 connectedSignals["aborted"] = 1; 147 } 148 onAbortedListeners ~= dlg; 149 } 150 extern(C) static void callBackAborted(GMountOperation* arg0Struct, MountOperation _mountOperation) 151 { 152 foreach ( void delegate(MountOperation) dlg ; _mountOperation.onAbortedListeners ) 153 { 154 dlg(_mountOperation); 155 } 156 } 157 158 void delegate(string, string, string, GAskPasswordFlags, MountOperation)[] onAskPasswordListeners; 159 /** 160 * Emitted when a mount operation asks the user for a password. 161 * If the message contains a line break, the first line should be 162 * presented as a heading. For example, it may be used as the 163 * primary text in a GtkMessageDialog. 164 */ 165 void addOnAskPassword(void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 166 { 167 if ( !("ask-password" in connectedSignals) ) 168 { 169 Signals.connectData( 170 getStruct(), 171 "ask-password", 172 cast(GCallback)&callBackAskPassword, 173 cast(void*)this, 174 null, 175 connectFlags); 176 connectedSignals["ask-password"] = 1; 177 } 178 onAskPasswordListeners ~= dlg; 179 } 180 extern(C) static void callBackAskPassword(GMountOperation* opStruct, gchar* message, gchar* defaultUser, gchar* defaultDomain, GAskPasswordFlags flags, MountOperation _mountOperation) 181 { 182 foreach ( void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg ; _mountOperation.onAskPasswordListeners ) 183 { 184 dlg(Str.toString(message), Str.toString(defaultUser), Str.toString(defaultDomain), flags, _mountOperation); 185 } 186 } 187 188 void delegate(string, GStrv, MountOperation)[] onAskQuestionListeners; 189 /** 190 * Emitted when asking the user a question and gives a list of 191 * choices for the user to choose from. 192 * If the message contains a line break, the first line should be 193 * presented as a heading. For example, it may be used as the 194 * primary text in a GtkMessageDialog. 195 */ 196 void addOnAskQuestion(void delegate(string, GStrv, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 197 { 198 if ( !("ask-question" in connectedSignals) ) 199 { 200 Signals.connectData( 201 getStruct(), 202 "ask-question", 203 cast(GCallback)&callBackAskQuestion, 204 cast(void*)this, 205 null, 206 connectFlags); 207 connectedSignals["ask-question"] = 1; 208 } 209 onAskQuestionListeners ~= dlg; 210 } 211 extern(C) static void callBackAskQuestion(GMountOperation* opStruct, gchar* message, GStrv choices, MountOperation _mountOperation) 212 { 213 foreach ( void delegate(string, GStrv, MountOperation) dlg ; _mountOperation.onAskQuestionListeners ) 214 { 215 dlg(Str.toString(message), choices, _mountOperation); 216 } 217 } 218 219 void delegate(GMountOperationResult, MountOperation)[] onReplyListeners; 220 /** 221 * Emitted when the user has replied to the mount operation. 222 */ 223 void addOnReply(void delegate(GMountOperationResult, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 224 { 225 if ( !("reply" in connectedSignals) ) 226 { 227 Signals.connectData( 228 getStruct(), 229 "reply", 230 cast(GCallback)&callBackReply, 231 cast(void*)this, 232 null, 233 connectFlags); 234 connectedSignals["reply"] = 1; 235 } 236 onReplyListeners ~= dlg; 237 } 238 extern(C) static void callBackReply(GMountOperation* opStruct, GMountOperationResult result, MountOperation _mountOperation) 239 { 240 foreach ( void delegate(GMountOperationResult, MountOperation) dlg ; _mountOperation.onReplyListeners ) 241 { 242 dlg(result, _mountOperation); 243 } 244 } 245 246 void delegate(string, ArrayG, GStrv, MountOperation)[] onShowProcessesListeners; 247 /** 248 * Emitted when one or more processes are blocking an operation 249 * e.g. unmounting/ejecting a GMount or stopping a GDrive. 250 * Note that this signal may be emitted several times to update the 251 * list of blocking processes as processes close files. The 252 * application should only respond with g_mount_operation_reply() to 253 * the latest signal (setting "choice" to the choice 254 * the user made). 255 * If the message contains a line break, the first line should be 256 * presented as a heading. For example, it may be used as the 257 * primary text in a GtkMessageDialog. 258 * Since 2.22 259 */ 260 void addOnShowProcesses(void delegate(string, ArrayG, GStrv, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 261 { 262 if ( !("show-processes" in connectedSignals) ) 263 { 264 Signals.connectData( 265 getStruct(), 266 "show-processes", 267 cast(GCallback)&callBackShowProcesses, 268 cast(void*)this, 269 null, 270 connectFlags); 271 connectedSignals["show-processes"] = 1; 272 } 273 onShowProcessesListeners ~= dlg; 274 } 275 extern(C) static void callBackShowProcesses(GMountOperation* opStruct, gchar* message, GArray* processes, GStrv choices, MountOperation _mountOperation) 276 { 277 foreach ( void delegate(string, ArrayG, GStrv, MountOperation) dlg ; _mountOperation.onShowProcessesListeners ) 278 { 279 dlg(Str.toString(message), ObjectG.getDObject!(ArrayG)(processes), choices, _mountOperation); 280 } 281 } 282 283 void delegate(string, gint64, gint64, MountOperation)[] onShowUnmountProgressListeners; 284 /** 285 * Emitted when an unmount operation has been busy for more than some time 286 * (typically 1.5 seconds). 287 * When unmounting or ejecting a volume, the kernel might need to flush 288 * pending data in its buffers to the volume stable storage, and this operation 289 * can take a considerable amount of time. This signal may be emitted several 290 * times as long as the unmount operation is outstanding, and then one 291 * last time when the operation is completed, with bytes_left set to zero. 292 * Implementations of GMountOperation should handle this signal by 293 * showing an UI notification, and then dismiss it, or show another notification 294 * of completion, when bytes_left reaches zero. 295 * If the message contains a line break, the first line should be 296 * presented as a heading. For example, it may be used as the 297 * primary text in a GtkMessageDialog. 298 * Since 2.34 299 */ 300 void addOnShowUnmountProgress(void delegate(string, gint64, gint64, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 301 { 302 if ( !("show-unmount-progress" in connectedSignals) ) 303 { 304 Signals.connectData( 305 getStruct(), 306 "show-unmount-progress", 307 cast(GCallback)&callBackShowUnmountProgress, 308 cast(void*)this, 309 null, 310 connectFlags); 311 connectedSignals["show-unmount-progress"] = 1; 312 } 313 onShowUnmountProgressListeners ~= dlg; 314 } 315 extern(C) static void callBackShowUnmountProgress(GMountOperation* opStruct, gchar* message, gint64 timeLeft, gint64 bytesLeft, MountOperation _mountOperation) 316 { 317 foreach ( void delegate(string, gint64, gint64, MountOperation) dlg ; _mountOperation.onShowUnmountProgressListeners ) 318 { 319 dlg(Str.toString(message), timeLeft, bytesLeft, _mountOperation); 320 } 321 } 322 323 324 /** 325 * Creates a new mount operation. 326 * Throws: ConstructionException GTK+ fails to create the object. 327 */ 328 public this () 329 { 330 // GMountOperation * g_mount_operation_new (void); 331 auto p = g_mount_operation_new(); 332 if(p is null) 333 { 334 throw new ConstructionException("null returned by g_mount_operation_new()"); 335 } 336 this(cast(GMountOperation*) p); 337 } 338 339 /** 340 * Get the user name from the mount operation. 341 * Returns: a string containing the user name. 342 */ 343 public string getUsername() 344 { 345 // const char * g_mount_operation_get_username (GMountOperation *op); 346 return Str.toString(g_mount_operation_get_username(gMountOperation)); 347 } 348 349 /** 350 * Sets the user name within op to username. 351 * Params: 352 * username = input username. 353 */ 354 public void setUsername(string username) 355 { 356 // void g_mount_operation_set_username (GMountOperation *op, const char *username); 357 g_mount_operation_set_username(gMountOperation, Str.toStringz(username)); 358 } 359 360 /** 361 * Gets a password from the mount operation. 362 * Returns: a string containing the password within op. 363 */ 364 public string getPassword() 365 { 366 // const char * g_mount_operation_get_password (GMountOperation *op); 367 return Str.toString(g_mount_operation_get_password(gMountOperation)); 368 } 369 370 /** 371 * Sets the mount operation's password to password. 372 * Params: 373 * password = password to set. 374 */ 375 public void setPassword(string password) 376 { 377 // void g_mount_operation_set_password (GMountOperation *op, const char *password); 378 g_mount_operation_set_password(gMountOperation, Str.toStringz(password)); 379 } 380 381 /** 382 * Check to see whether the mount operation is being used 383 * for an anonymous user. 384 * Returns: TRUE if mount operation is anonymous. 385 */ 386 public int getAnonymous() 387 { 388 // gboolean g_mount_operation_get_anonymous (GMountOperation *op); 389 return g_mount_operation_get_anonymous(gMountOperation); 390 } 391 392 /** 393 * Sets the mount operation to use an anonymous user if anonymous is TRUE. 394 * Params: 395 * anonymous = boolean value. 396 */ 397 public void setAnonymous(int anonymous) 398 { 399 // void g_mount_operation_set_anonymous (GMountOperation *op, gboolean anonymous); 400 g_mount_operation_set_anonymous(gMountOperation, anonymous); 401 } 402 403 /** 404 * Gets the domain of the mount operation. 405 * Returns: a string set to the domain. 406 */ 407 public string getDomain() 408 { 409 // const char * g_mount_operation_get_domain (GMountOperation *op); 410 return Str.toString(g_mount_operation_get_domain(gMountOperation)); 411 } 412 413 /** 414 * Sets the mount operation's domain. 415 * Params: 416 * domain = the domain to set. 417 */ 418 public void setDomain(string domain) 419 { 420 // void g_mount_operation_set_domain (GMountOperation *op, const char *domain); 421 g_mount_operation_set_domain(gMountOperation, Str.toStringz(domain)); 422 } 423 424 /** 425 * Gets the state of saving passwords for the mount operation. 426 * Returns: a GPasswordSave flag. 427 */ 428 public GPasswordSave getPasswordSave() 429 { 430 // GPasswordSave g_mount_operation_get_password_save (GMountOperation *op); 431 return g_mount_operation_get_password_save(gMountOperation); 432 } 433 434 /** 435 * Sets the state of saving passwords for the mount operation. 436 * Params: 437 * save = a set of GPasswordSave flags. 438 */ 439 public void setPasswordSave(GPasswordSave save) 440 { 441 // void g_mount_operation_set_password_save (GMountOperation *op, GPasswordSave save); 442 g_mount_operation_set_password_save(gMountOperation, save); 443 } 444 445 /** 446 * Gets a choice from the mount operation. 447 * Returns: an integer containing an index of the user's choice from the choice's list, or 0. 448 */ 449 public int getChoice() 450 { 451 // int g_mount_operation_get_choice (GMountOperation *op); 452 return g_mount_operation_get_choice(gMountOperation); 453 } 454 455 /** 456 * Sets a default choice for the mount operation. 457 * Params: 458 * choice = an integer. 459 */ 460 public void setChoice(int choice) 461 { 462 // void g_mount_operation_set_choice (GMountOperation *op, int choice); 463 g_mount_operation_set_choice(gMountOperation, choice); 464 } 465 466 /** 467 * Emits the "reply" signal. 468 * Params: 469 * result = a GMountOperationResult 470 */ 471 public void reply(GMountOperationResult result) 472 { 473 // void g_mount_operation_reply (GMountOperation *op, GMountOperationResult result); 474 g_mount_operation_reply(gMountOperation, result); 475 } 476 }