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 gtk.PlacesSidebar; 26 27 private import gdk.DragContext; 28 private import gio.FileIF; 29 private import gio.MountOperation; 30 private import gio.VolumeIF; 31 private import glib.ConstructionException; 32 private import glib.ListG; 33 private import glib.ListSG; 34 private import glib.Str; 35 private import gobject.ObjectG; 36 private import gobject.Signals; 37 private import gtk.ScrolledWindow; 38 private import gtk.Widget; 39 private import gtk.c.functions; 40 public import gtk.c.types; 41 public import gtkc.gtktypes; 42 private import std.algorithm; 43 44 45 /** 46 * #GtkPlacesSidebar is a widget that displays a list of frequently-used places in the 47 * file system: the user’s home directory, the user’s bookmarks, and volumes and drives. 48 * This widget is used as a sidebar in #GtkFileChooser and may be used by file managers 49 * and similar programs. 50 * 51 * The places sidebar displays drives and volumes, and will automatically mount 52 * or unmount them when the user selects them. 53 * 54 * Applications can hook to various signals in the places sidebar to customize 55 * its behavior. For example, they can add extra commands to the context menu 56 * of the sidebar. 57 * 58 * While bookmarks are completely in control of the user, the places sidebar also 59 * allows individual applications to provide extra shortcut folders that are unique 60 * to each application. For example, a Paint program may want to add a shortcut 61 * for a Clipart folder. You can do this with gtk_places_sidebar_add_shortcut(). 62 * 63 * To make use of the places sidebar, an application at least needs to connect 64 * to the #GtkPlacesSidebar::open-location signal. This is emitted when the 65 * user selects in the sidebar a location to open. The application should also 66 * call gtk_places_sidebar_set_location() when it changes the currently-viewed 67 * location. 68 * 69 * # CSS nodes 70 * 71 * GtkPlacesSidebar uses a single CSS node with name placessidebar and style 72 * class .sidebar. 73 * 74 * Among the children of the places sidebar, the following style classes can 75 * be used: 76 * - .sidebar-new-bookmark-row for the 'Add new bookmark' row 77 * - .sidebar-placeholder-row for a row that is a placeholder 78 * - .has-open-popup when a popup is open for a row 79 */ 80 public class PlacesSidebar : ScrolledWindow 81 { 82 /** the main Gtk struct */ 83 protected GtkPlacesSidebar* gtkPlacesSidebar; 84 85 /** Get the main Gtk struct */ 86 public GtkPlacesSidebar* getPlacesSidebarStruct(bool transferOwnership = false) 87 { 88 if (transferOwnership) 89 ownedRef = false; 90 return gtkPlacesSidebar; 91 } 92 93 /** the main Gtk struct as a void* */ 94 protected override void* getStruct() 95 { 96 return cast(void*)gtkPlacesSidebar; 97 } 98 99 protected override void setStruct(GObject* obj) 100 { 101 gtkPlacesSidebar = cast(GtkPlacesSidebar*)obj; 102 super.setStruct(obj); 103 } 104 105 /** 106 * Sets our main struct and passes it to the parent class. 107 */ 108 public this (GtkPlacesSidebar* gtkPlacesSidebar, bool ownedRef = false) 109 { 110 this.gtkPlacesSidebar = gtkPlacesSidebar; 111 super(cast(GtkScrolledWindow*)gtkPlacesSidebar, ownedRef); 112 } 113 114 115 /** */ 116 public static GType getType() 117 { 118 return gtk_places_sidebar_get_type(); 119 } 120 121 /** 122 * Creates a new #GtkPlacesSidebar widget. 123 * 124 * The application should connect to at least the 125 * #GtkPlacesSidebar::open-location signal to be notified 126 * when the user makes a selection in the sidebar. 127 * 128 * Returns: a newly created #GtkPlacesSidebar 129 * 130 * Since: 3.10 131 * 132 * Throws: ConstructionException GTK+ fails to create the object. 133 */ 134 public this() 135 { 136 auto p = gtk_places_sidebar_new(); 137 138 if(p is null) 139 { 140 throw new ConstructionException("null returned by new"); 141 } 142 143 this(cast(GtkPlacesSidebar*) p); 144 } 145 146 /** 147 * Applications may want to present some folders in the places sidebar if 148 * they could be immediately useful to users. For example, a drawing 149 * program could add a “/usr/share/clipart” location when the sidebar is 150 * being used in an “Insert Clipart” dialog box. 151 * 152 * This function adds the specified @location to a special place for immutable 153 * shortcuts. The shortcuts are application-specific; they are not shared 154 * across applications, and they are not persistent. If this function 155 * is called multiple times with different locations, then they are added 156 * to the sidebar’s list in the same order as the function is called. 157 * 158 * Params: 159 * location = location to add as an application-specific shortcut 160 * 161 * Since: 3.10 162 */ 163 public void addShortcut(FileIF location) 164 { 165 gtk_places_sidebar_add_shortcut(gtkPlacesSidebar, (location is null) ? null : location.getFileStruct()); 166 } 167 168 /** 169 * Returns the value previously set with gtk_places_sidebar_set_local_only(). 170 * 171 * Returns: %TRUE if the sidebar will only show local files. 172 * 173 * Since: 3.12 174 */ 175 public bool getLocalOnly() 176 { 177 return gtk_places_sidebar_get_local_only(gtkPlacesSidebar) != 0; 178 } 179 180 /** 181 * Gets the currently-selected location in the @sidebar. This can be #NULL when 182 * nothing is selected, for example, when gtk_places_sidebar_set_location() has 183 * been called with a location that is not among the sidebar’s list of places to 184 * show. 185 * 186 * You can use this function to get the selection in the @sidebar. Also, if you 187 * connect to the #GtkPlacesSidebar::populate-popup signal, you can use this 188 * function to get the location that is being referred to during the callbacks 189 * for your menu items. 190 * 191 * Returns: a GFile with the selected location, or 192 * %NULL if nothing is visually selected. 193 * 194 * Since: 3.10 195 */ 196 public FileIF getLocation() 197 { 198 auto p = gtk_places_sidebar_get_location(gtkPlacesSidebar); 199 200 if(p is null) 201 { 202 return null; 203 } 204 205 return ObjectG.getDObject!(FileIF)(cast(GFile*) p, true); 206 } 207 208 /** 209 * This function queries the bookmarks added by the user to the places sidebar, 210 * and returns one of them. This function is used by #GtkFileChooser to implement 211 * the “Alt-1”, “Alt-2”, etc. shortcuts, which activate the cooresponding bookmark. 212 * 213 * Params: 214 * n = index of the bookmark to query 215 * 216 * Returns: The bookmark specified by the index @n, or 217 * %NULL if no such index exist. Note that the indices start at 0, even though 218 * the file chooser starts them with the keyboard shortcut "Alt-1". 219 * 220 * Since: 3.10 221 */ 222 public FileIF getNthBookmark(int n) 223 { 224 auto p = gtk_places_sidebar_get_nth_bookmark(gtkPlacesSidebar, n); 225 226 if(p is null) 227 { 228 return null; 229 } 230 231 return ObjectG.getDObject!(FileIF)(cast(GFile*) p, true); 232 } 233 234 /** 235 * Gets the open flags. 236 * 237 * Returns: the #GtkPlacesOpenFlags of @sidebar 238 * 239 * Since: 3.10 240 */ 241 public GtkPlacesOpenFlags getOpenFlags() 242 { 243 return gtk_places_sidebar_get_open_flags(gtkPlacesSidebar); 244 } 245 246 /** 247 * Returns the value previously set with gtk_places_sidebar_set_show_connect_to_server() 248 * 249 * Deprecated: It is recommended to group this functionality with the drives 250 * and network location under the new 'Other Location' item 251 * 252 * Returns: %TRUE if the sidebar will display a “Connect to Server” item. 253 */ 254 public bool getShowConnectToServer() 255 { 256 return gtk_places_sidebar_get_show_connect_to_server(gtkPlacesSidebar) != 0; 257 } 258 259 /** 260 * Returns the value previously set with gtk_places_sidebar_set_show_desktop() 261 * 262 * Returns: %TRUE if the sidebar will display a builtin shortcut to the desktop folder. 263 * 264 * Since: 3.10 265 */ 266 public bool getShowDesktop() 267 { 268 return gtk_places_sidebar_get_show_desktop(gtkPlacesSidebar) != 0; 269 } 270 271 /** 272 * Returns the value previously set with gtk_places_sidebar_set_show_enter_location() 273 * 274 * Returns: %TRUE if the sidebar will display an “Enter Location” item. 275 * 276 * Since: 3.14 277 */ 278 public bool getShowEnterLocation() 279 { 280 return gtk_places_sidebar_get_show_enter_location(gtkPlacesSidebar) != 0; 281 } 282 283 /** 284 * Returns the value previously set with gtk_places_sidebar_set_show_other_locations() 285 * 286 * Returns: %TRUE if the sidebar will display an “Other Locations” item. 287 * 288 * Since: 3.18 289 */ 290 public bool getShowOtherLocations() 291 { 292 return gtk_places_sidebar_get_show_other_locations(gtkPlacesSidebar) != 0; 293 } 294 295 /** 296 * Returns the value previously set with gtk_places_sidebar_set_show_recent() 297 * 298 * Returns: %TRUE if the sidebar will display a builtin shortcut for recent files 299 * 300 * Since: 3.18 301 */ 302 public bool getShowRecent() 303 { 304 return gtk_places_sidebar_get_show_recent(gtkPlacesSidebar) != 0; 305 } 306 307 /** 308 * Returns the value previously set with gtk_places_sidebar_set_show_starred_location() 309 * 310 * Returns: %TRUE if the sidebar will display a Starred item. 311 * 312 * Since: 3.22.26 313 */ 314 public bool getShowStarredLocation() 315 { 316 return gtk_places_sidebar_get_show_starred_location(gtkPlacesSidebar) != 0; 317 } 318 319 /** 320 * Returns the value previously set with gtk_places_sidebar_set_show_trash() 321 * 322 * Returns: %TRUE if the sidebar will display a “Trash” item. 323 * 324 * Since: 3.18 325 */ 326 public bool getShowTrash() 327 { 328 return gtk_places_sidebar_get_show_trash(gtkPlacesSidebar) != 0; 329 } 330 331 /** 332 * Gets the list of shortcuts. 333 * 334 * Returns: A #GSList of #GFile of the locations that have been added as 335 * application-specific shortcuts with gtk_places_sidebar_add_shortcut(). 336 * To free this list, you can use 337 * |[<!-- language="C" --> 338 * g_slist_free_full (list, (GDestroyNotify) g_object_unref); 339 * ]| 340 * 341 * Since: 3.10 342 */ 343 public ListSG listShortcuts() 344 { 345 auto p = gtk_places_sidebar_list_shortcuts(gtkPlacesSidebar); 346 347 if(p is null) 348 { 349 return null; 350 } 351 352 return new ListSG(cast(GSList*) p, true); 353 } 354 355 /** 356 * Removes an application-specific shortcut that has been previously been 357 * inserted with gtk_places_sidebar_add_shortcut(). If the @location is not a 358 * shortcut in the sidebar, then nothing is done. 359 * 360 * Params: 361 * location = location to remove 362 * 363 * Since: 3.10 364 */ 365 public void removeShortcut(FileIF location) 366 { 367 gtk_places_sidebar_remove_shortcut(gtkPlacesSidebar, (location is null) ? null : location.getFileStruct()); 368 } 369 370 /** 371 * Make the GtkPlacesSidebar show drop targets, so it can show the available 372 * drop targets and a "new bookmark" row. This improves the Drag-and-Drop 373 * experience of the user and allows applications to show all available 374 * drop targets at once. 375 * 376 * This needs to be called when the application is aware of an ongoing drag 377 * that might target the sidebar. The drop-targets-visible state will be unset 378 * automatically if the drag finishes in the GtkPlacesSidebar. You only need 379 * to unset the state when the drag ends on some other widget on your application. 380 * 381 * Params: 382 * visible = whether to show the valid targets or not. 383 * context = drag context used to ask the source about the action that wants to 384 * perform, so hints are more accurate. 385 * 386 * Since: 3.18 387 */ 388 public void setDropTargetsVisible(bool visible, DragContext context) 389 { 390 gtk_places_sidebar_set_drop_targets_visible(gtkPlacesSidebar, visible, (context is null) ? null : context.getDragContextStruct()); 391 } 392 393 /** 394 * Sets whether the @sidebar should only show local files. 395 * 396 * Params: 397 * localOnly = whether to show only local files 398 * 399 * Since: 3.12 400 */ 401 public void setLocalOnly(bool localOnly) 402 { 403 gtk_places_sidebar_set_local_only(gtkPlacesSidebar, localOnly); 404 } 405 406 /** 407 * Sets the location that is being shown in the widgets surrounding the 408 * @sidebar, for example, in a folder view in a file manager. In turn, the 409 * @sidebar will highlight that location if it is being shown in the list of 410 * places, or it will unhighlight everything if the @location is not among the 411 * places in the list. 412 * 413 * Params: 414 * location = location to select, or #NULL for no current path 415 * 416 * Since: 3.10 417 */ 418 public void setLocation(FileIF location) 419 { 420 gtk_places_sidebar_set_location(gtkPlacesSidebar, (location is null) ? null : location.getFileStruct()); 421 } 422 423 /** 424 * Sets the way in which the calling application can open new locations from 425 * the places sidebar. For example, some applications only open locations 426 * “directly” into their main view, while others may support opening locations 427 * in a new notebook tab or a new window. 428 * 429 * This function is used to tell the places @sidebar about the ways in which the 430 * application can open new locations, so that the sidebar can display (or not) 431 * the “Open in new tab” and “Open in new window” menu items as appropriate. 432 * 433 * When the #GtkPlacesSidebar::open-location signal is emitted, its flags 434 * argument will be set to one of the @flags that was passed in 435 * gtk_places_sidebar_set_open_flags(). 436 * 437 * Passing 0 for @flags will cause #GTK_PLACES_OPEN_NORMAL to always be sent 438 * to callbacks for the “open-location” signal. 439 * 440 * Params: 441 * flags = Bitmask of modes in which the calling application can open locations 442 * 443 * Since: 3.10 444 */ 445 public void setOpenFlags(GtkPlacesOpenFlags flags) 446 { 447 gtk_places_sidebar_set_open_flags(gtkPlacesSidebar, flags); 448 } 449 450 /** 451 * Sets whether the @sidebar should show an item for connecting to a network server; 452 * this is off by default. An application may want to turn this on if it implements 453 * a way for the user to connect to network servers directly. 454 * 455 * If you enable this, you should connect to the 456 * #GtkPlacesSidebar::show-connect-to-server signal. 457 * 458 * Deprecated: It is recommended to group this functionality with the drives 459 * and network location under the new 'Other Location' item 460 * 461 * Params: 462 * showConnectToServer = whether to show an item for the Connect to Server command 463 * 464 * Since: 3.10 465 */ 466 public void setShowConnectToServer(bool showConnectToServer) 467 { 468 gtk_places_sidebar_set_show_connect_to_server(gtkPlacesSidebar, showConnectToServer); 469 } 470 471 /** 472 * Sets whether the @sidebar should show an item for the Desktop folder. 473 * The default value for this option is determined by the desktop 474 * environment and the user’s configuration, but this function can be 475 * used to override it on a per-application basis. 476 * 477 * Params: 478 * showDesktop = whether to show an item for the Desktop folder 479 * 480 * Since: 3.10 481 */ 482 public void setShowDesktop(bool showDesktop) 483 { 484 gtk_places_sidebar_set_show_desktop(gtkPlacesSidebar, showDesktop); 485 } 486 487 /** 488 * Sets whether the @sidebar should show an item for entering a location; 489 * this is off by default. An application may want to turn this on if manually 490 * entering URLs is an expected user action. 491 * 492 * If you enable this, you should connect to the 493 * #GtkPlacesSidebar::show-enter-location signal. 494 * 495 * Params: 496 * showEnterLocation = whether to show an item to enter a location 497 * 498 * Since: 3.14 499 */ 500 public void setShowEnterLocation(bool showEnterLocation) 501 { 502 gtk_places_sidebar_set_show_enter_location(gtkPlacesSidebar, showEnterLocation); 503 } 504 505 /** 506 * Sets whether the @sidebar should show an item for the application to show 507 * an Other Locations view; this is off by default. When set to %TRUE, persistent 508 * devices such as hard drives are hidden, otherwise they are shown in the sidebar. 509 * An application may want to turn this on if it implements a way for the user to 510 * see and interact with drives and network servers directly. 511 * 512 * If you enable this, you should connect to the 513 * #GtkPlacesSidebar::show-other-locations signal. 514 * 515 * Params: 516 * showOtherLocations = whether to show an item for the Other Locations view 517 * 518 * Since: 3.18 519 */ 520 public void setShowOtherLocations(bool showOtherLocations) 521 { 522 gtk_places_sidebar_set_show_other_locations(gtkPlacesSidebar, showOtherLocations); 523 } 524 525 /** 526 * Sets whether the @sidebar should show an item for recent files. 527 * The default value for this option is determined by the desktop 528 * environment, but this function can be used to override it on a 529 * per-application basis. 530 * 531 * Params: 532 * showRecent = whether to show an item for recent files 533 * 534 * Since: 3.18 535 */ 536 public void setShowRecent(bool showRecent) 537 { 538 gtk_places_sidebar_set_show_recent(gtkPlacesSidebar, showRecent); 539 } 540 541 /** 542 * If you enable this, you should connect to the 543 * #GtkPlacesSidebar::show-starred-location signal. 544 * 545 * Params: 546 * showStarredLocation = whether to show an item for Starred files 547 * 548 * Since: 3.22.26 549 */ 550 public void setShowStarredLocation(bool showStarredLocation) 551 { 552 gtk_places_sidebar_set_show_starred_location(gtkPlacesSidebar, showStarredLocation); 553 } 554 555 /** 556 * Sets whether the @sidebar should show an item for the Trash location. 557 * 558 * Params: 559 * showTrash = whether to show an item for the Trash location 560 * 561 * Since: 3.18 562 */ 563 public void setShowTrash(bool showTrash) 564 { 565 gtk_places_sidebar_set_show_trash(gtkPlacesSidebar, showTrash); 566 } 567 568 protected class OnDragActionAskDelegateWrapper 569 { 570 int delegate(int, PlacesSidebar) dlg; 571 gulong handlerId; 572 573 this(int delegate(int, PlacesSidebar) dlg) 574 { 575 this.dlg = dlg; 576 onDragActionAskListeners ~= this; 577 } 578 579 void remove(OnDragActionAskDelegateWrapper source) 580 { 581 foreach(index, wrapper; onDragActionAskListeners) 582 { 583 if (wrapper.handlerId == source.handlerId) 584 { 585 onDragActionAskListeners[index] = null; 586 onDragActionAskListeners = std.algorithm.remove(onDragActionAskListeners, index); 587 break; 588 } 589 } 590 } 591 } 592 OnDragActionAskDelegateWrapper[] onDragActionAskListeners; 593 594 /** 595 * The places sidebar emits this signal when it needs to ask the application 596 * to pop up a menu to ask the user for which drag action to perform. 597 * 598 * Params: 599 * actions = Possible drag actions that need to be asked for. 600 * 601 * Returns: the final drag action that the sidebar should pass to the drag side 602 * of the drag-and-drop operation. 603 * 604 * Since: 3.10 605 */ 606 gulong addOnDragActionAsk(int delegate(int, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 607 { 608 auto wrapper = new OnDragActionAskDelegateWrapper(dlg); 609 wrapper.handlerId = Signals.connectData( 610 this, 611 "drag-action-ask", 612 cast(GCallback)&callBackDragActionAsk, 613 cast(void*)wrapper, 614 cast(GClosureNotify)&callBackDragActionAskDestroy, 615 connectFlags); 616 return wrapper.handlerId; 617 } 618 619 extern(C) static int callBackDragActionAsk(GtkPlacesSidebar* placessidebarStruct, int actions, OnDragActionAskDelegateWrapper wrapper) 620 { 621 return wrapper.dlg(actions, wrapper.outer); 622 } 623 624 extern(C) static void callBackDragActionAskDestroy(OnDragActionAskDelegateWrapper wrapper, GClosure* closure) 625 { 626 wrapper.remove(wrapper); 627 } 628 629 protected class OnDragActionRequestedDelegateWrapper 630 { 631 int delegate(DragContext, FileIF, ListG, PlacesSidebar) dlg; 632 gulong handlerId; 633 634 this(int delegate(DragContext, FileIF, ListG, PlacesSidebar) dlg) 635 { 636 this.dlg = dlg; 637 onDragActionRequestedListeners ~= this; 638 } 639 640 void remove(OnDragActionRequestedDelegateWrapper source) 641 { 642 foreach(index, wrapper; onDragActionRequestedListeners) 643 { 644 if (wrapper.handlerId == source.handlerId) 645 { 646 onDragActionRequestedListeners[index] = null; 647 onDragActionRequestedListeners = std.algorithm.remove(onDragActionRequestedListeners, index); 648 break; 649 } 650 } 651 } 652 } 653 OnDragActionRequestedDelegateWrapper[] onDragActionRequestedListeners; 654 655 /** 656 * When the user starts a drag-and-drop operation and the sidebar needs 657 * to ask the application for which drag action to perform, then the 658 * sidebar will emit this signal. 659 * 660 * The application can evaluate the @context for customary actions, or 661 * it can check the type of the files indicated by @source_file_list against the 662 * possible actions for the destination @dest_file. 663 * 664 * The drag action to use must be the return value of the signal handler. 665 * 666 * Params: 667 * context = #GdkDragContext with information about the drag operation 668 * destFile = #GFile with the tentative location that is being hovered for a drop 669 * sourceFileList = List of #GFile that are being dragged 670 * 671 * Returns: The drag action to use, for example, #GDK_ACTION_COPY 672 * or #GDK_ACTION_MOVE, or 0 if no action is allowed here (i.e. drops 673 * are not allowed in the specified @dest_file). 674 * 675 * Since: 3.10 676 */ 677 gulong addOnDragActionRequested(int delegate(DragContext, FileIF, ListG, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 678 { 679 auto wrapper = new OnDragActionRequestedDelegateWrapper(dlg); 680 wrapper.handlerId = Signals.connectData( 681 this, 682 "drag-action-requested", 683 cast(GCallback)&callBackDragActionRequested, 684 cast(void*)wrapper, 685 cast(GClosureNotify)&callBackDragActionRequestedDestroy, 686 connectFlags); 687 return wrapper.handlerId; 688 } 689 690 extern(C) static int callBackDragActionRequested(GtkPlacesSidebar* placessidebarStruct, GdkDragContext* context, GFile* destFile, GList* sourceFileList, OnDragActionRequestedDelegateWrapper wrapper) 691 { 692 return wrapper.dlg(ObjectG.getDObject!(DragContext)(context), ObjectG.getDObject!(FileIF)(destFile), new ListG(sourceFileList), wrapper.outer); 693 } 694 695 extern(C) static void callBackDragActionRequestedDestroy(OnDragActionRequestedDelegateWrapper wrapper, GClosure* closure) 696 { 697 wrapper.remove(wrapper); 698 } 699 700 protected class OnDragPerformDropDelegateWrapper 701 { 702 void delegate(FileIF, ListG, int, PlacesSidebar) dlg; 703 gulong handlerId; 704 705 this(void delegate(FileIF, ListG, int, PlacesSidebar) dlg) 706 { 707 this.dlg = dlg; 708 onDragPerformDropListeners ~= this; 709 } 710 711 void remove(OnDragPerformDropDelegateWrapper source) 712 { 713 foreach(index, wrapper; onDragPerformDropListeners) 714 { 715 if (wrapper.handlerId == source.handlerId) 716 { 717 onDragPerformDropListeners[index] = null; 718 onDragPerformDropListeners = std.algorithm.remove(onDragPerformDropListeners, index); 719 break; 720 } 721 } 722 } 723 } 724 OnDragPerformDropDelegateWrapper[] onDragPerformDropListeners; 725 726 /** 727 * The places sidebar emits this signal when the user completes a 728 * drag-and-drop operation and one of the sidebar's items is the 729 * destination. This item is in the @dest_file, and the 730 * @source_file_list has the list of files that are dropped into it and 731 * which should be copied/moved/etc. based on the specified @action. 732 * 733 * Params: 734 * destFile = Destination #GFile. 735 * sourceFileList = #GList of #GFile that got dropped. 736 * action = Drop action to perform. 737 * 738 * Since: 3.10 739 */ 740 gulong addOnDragPerformDrop(void delegate(FileIF, ListG, int, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 741 { 742 auto wrapper = new OnDragPerformDropDelegateWrapper(dlg); 743 wrapper.handlerId = Signals.connectData( 744 this, 745 "drag-perform-drop", 746 cast(GCallback)&callBackDragPerformDrop, 747 cast(void*)wrapper, 748 cast(GClosureNotify)&callBackDragPerformDropDestroy, 749 connectFlags); 750 return wrapper.handlerId; 751 } 752 753 extern(C) static void callBackDragPerformDrop(GtkPlacesSidebar* placessidebarStruct, GFile* destFile, GList* sourceFileList, int action, OnDragPerformDropDelegateWrapper wrapper) 754 { 755 wrapper.dlg(ObjectG.getDObject!(FileIF)(destFile), new ListG(sourceFileList), action, wrapper.outer); 756 } 757 758 extern(C) static void callBackDragPerformDropDestroy(OnDragPerformDropDelegateWrapper wrapper, GClosure* closure) 759 { 760 wrapper.remove(wrapper); 761 } 762 763 protected class OnMountDelegateWrapper 764 { 765 void delegate(MountOperation, PlacesSidebar) dlg; 766 gulong handlerId; 767 768 this(void delegate(MountOperation, PlacesSidebar) dlg) 769 { 770 this.dlg = dlg; 771 onMountListeners ~= this; 772 } 773 774 void remove(OnMountDelegateWrapper source) 775 { 776 foreach(index, wrapper; onMountListeners) 777 { 778 if (wrapper.handlerId == source.handlerId) 779 { 780 onMountListeners[index] = null; 781 onMountListeners = std.algorithm.remove(onMountListeners, index); 782 break; 783 } 784 } 785 } 786 } 787 OnMountDelegateWrapper[] onMountListeners; 788 789 /** 790 * The places sidebar emits this signal when it starts a new operation 791 * because the user clicked on some location that needs mounting. 792 * In this way the application using the #GtkPlacesSidebar can track the 793 * progress of the operation and, for example, show a notification. 794 * 795 * Params: 796 * mountOperation = the #GMountOperation that is going to start. 797 * 798 * Since: 3.20 799 */ 800 gulong addOnMount(void delegate(MountOperation, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 801 { 802 auto wrapper = new OnMountDelegateWrapper(dlg); 803 wrapper.handlerId = Signals.connectData( 804 this, 805 "mount", 806 cast(GCallback)&callBackMount, 807 cast(void*)wrapper, 808 cast(GClosureNotify)&callBackMountDestroy, 809 connectFlags); 810 return wrapper.handlerId; 811 } 812 813 extern(C) static void callBackMount(GtkPlacesSidebar* placessidebarStruct, GMountOperation* mountOperation, OnMountDelegateWrapper wrapper) 814 { 815 wrapper.dlg(ObjectG.getDObject!(MountOperation)(mountOperation), wrapper.outer); 816 } 817 818 extern(C) static void callBackMountDestroy(OnMountDelegateWrapper wrapper, GClosure* closure) 819 { 820 wrapper.remove(wrapper); 821 } 822 823 protected class OnOpenLocationDelegateWrapper 824 { 825 void delegate(FileIF, GtkPlacesOpenFlags, PlacesSidebar) dlg; 826 gulong handlerId; 827 828 this(void delegate(FileIF, GtkPlacesOpenFlags, PlacesSidebar) dlg) 829 { 830 this.dlg = dlg; 831 onOpenLocationListeners ~= this; 832 } 833 834 void remove(OnOpenLocationDelegateWrapper source) 835 { 836 foreach(index, wrapper; onOpenLocationListeners) 837 { 838 if (wrapper.handlerId == source.handlerId) 839 { 840 onOpenLocationListeners[index] = null; 841 onOpenLocationListeners = std.algorithm.remove(onOpenLocationListeners, index); 842 break; 843 } 844 } 845 } 846 } 847 OnOpenLocationDelegateWrapper[] onOpenLocationListeners; 848 849 /** 850 * The places sidebar emits this signal when the user selects a location 851 * in it. The calling application should display the contents of that 852 * location; for example, a file manager should show a list of files in 853 * the specified location. 854 * 855 * Params: 856 * location = #GFile to which the caller should switch. 857 * openFlags = a single value from #GtkPlacesOpenFlags specifying how the @location should be opened. 858 * 859 * Since: 3.10 860 */ 861 gulong addOnOpenLocation(void delegate(FileIF, GtkPlacesOpenFlags, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 862 { 863 auto wrapper = new OnOpenLocationDelegateWrapper(dlg); 864 wrapper.handlerId = Signals.connectData( 865 this, 866 "open-location", 867 cast(GCallback)&callBackOpenLocation, 868 cast(void*)wrapper, 869 cast(GClosureNotify)&callBackOpenLocationDestroy, 870 connectFlags); 871 return wrapper.handlerId; 872 } 873 874 extern(C) static void callBackOpenLocation(GtkPlacesSidebar* placessidebarStruct, GFile* location, GtkPlacesOpenFlags openFlags, OnOpenLocationDelegateWrapper wrapper) 875 { 876 wrapper.dlg(ObjectG.getDObject!(FileIF)(location), openFlags, wrapper.outer); 877 } 878 879 extern(C) static void callBackOpenLocationDestroy(OnOpenLocationDelegateWrapper wrapper, GClosure* closure) 880 { 881 wrapper.remove(wrapper); 882 } 883 884 protected class OnPopulatePopupDelegateWrapper 885 { 886 void delegate(Widget, FileIF, VolumeIF, PlacesSidebar) dlg; 887 gulong handlerId; 888 889 this(void delegate(Widget, FileIF, VolumeIF, PlacesSidebar) dlg) 890 { 891 this.dlg = dlg; 892 onPopulatePopupListeners ~= this; 893 } 894 895 void remove(OnPopulatePopupDelegateWrapper source) 896 { 897 foreach(index, wrapper; onPopulatePopupListeners) 898 { 899 if (wrapper.handlerId == source.handlerId) 900 { 901 onPopulatePopupListeners[index] = null; 902 onPopulatePopupListeners = std.algorithm.remove(onPopulatePopupListeners, index); 903 break; 904 } 905 } 906 } 907 } 908 OnPopulatePopupDelegateWrapper[] onPopulatePopupListeners; 909 910 /** 911 * The places sidebar emits this signal when the user invokes a contextual 912 * popup on one of its items. In the signal handler, the application may 913 * add extra items to the menu as appropriate. For example, a file manager 914 * may want to add a "Properties" command to the menu. 915 * 916 * It is not necessary to store the @selected_item for each menu item; 917 * during their callbacks, the application can use gtk_places_sidebar_get_location() 918 * to get the file to which the item refers. 919 * 920 * The @selected_item argument may be %NULL in case the selection refers to 921 * a volume. In this case, @selected_volume will be non-%NULL. In this case, 922 * the calling application will have to g_object_ref() the @selected_volume and 923 * keep it around to use it in the callback. 924 * 925 * The @container and all its contents are destroyed after the user 926 * dismisses the popup. The popup is re-created (and thus, this signal is 927 * emitted) every time the user activates the contextual menu. 928 * 929 * Before 3.18, the @container always was a #GtkMenu, and you were expected 930 * to add your items as #GtkMenuItems. Since 3.18, the popup may be implemented 931 * as a #GtkPopover, in which case @container will be something else, e.g. a 932 * #GtkBox, to which you may add #GtkModelButtons or other widgets, such as 933 * #GtkEntries, #GtkSpinButtons, etc. If your application can deal with this 934 * situation, you can set #GtkPlacesSidebar::populate-all to %TRUE to request 935 * that this signal is emitted for populating popovers as well. 936 * 937 * Params: 938 * container = a #GtkMenu or another #GtkContainer 939 * selectedItem = #GFile with the item to which the popup should refer, or #NULL in the case of a @selected_volume. 940 * selectedVolume = #GVolume if the selected item is a volume, or #NULL if it is a file. 941 * 942 * Since: 3.10 943 */ 944 gulong addOnPopulatePopup(void delegate(Widget, FileIF, VolumeIF, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 945 { 946 auto wrapper = new OnPopulatePopupDelegateWrapper(dlg); 947 wrapper.handlerId = Signals.connectData( 948 this, 949 "populate-popup", 950 cast(GCallback)&callBackPopulatePopup, 951 cast(void*)wrapper, 952 cast(GClosureNotify)&callBackPopulatePopupDestroy, 953 connectFlags); 954 return wrapper.handlerId; 955 } 956 957 extern(C) static void callBackPopulatePopup(GtkPlacesSidebar* placessidebarStruct, GtkWidget* container, GFile* selectedItem, GVolume* selectedVolume, OnPopulatePopupDelegateWrapper wrapper) 958 { 959 wrapper.dlg(ObjectG.getDObject!(Widget)(container), ObjectG.getDObject!(FileIF)(selectedItem), ObjectG.getDObject!(VolumeIF)(selectedVolume), wrapper.outer); 960 } 961 962 extern(C) static void callBackPopulatePopupDestroy(OnPopulatePopupDelegateWrapper wrapper, GClosure* closure) 963 { 964 wrapper.remove(wrapper); 965 } 966 967 protected class OnShowConnectToServerDelegateWrapper 968 { 969 void delegate(PlacesSidebar) dlg; 970 gulong handlerId; 971 972 this(void delegate(PlacesSidebar) dlg) 973 { 974 this.dlg = dlg; 975 onShowConnectToServerListeners ~= this; 976 } 977 978 void remove(OnShowConnectToServerDelegateWrapper source) 979 { 980 foreach(index, wrapper; onShowConnectToServerListeners) 981 { 982 if (wrapper.handlerId == source.handlerId) 983 { 984 onShowConnectToServerListeners[index] = null; 985 onShowConnectToServerListeners = std.algorithm.remove(onShowConnectToServerListeners, index); 986 break; 987 } 988 } 989 } 990 } 991 OnShowConnectToServerDelegateWrapper[] onShowConnectToServerListeners; 992 993 /** 994 * The places sidebar emits this signal when it needs the calling 995 * application to present an way to connect directly to a network server. 996 * For example, the application may bring up a dialog box asking for 997 * a URL like "sftp://ftp.example.com". It is up to the application to create 998 * the corresponding mount by using, for example, g_file_mount_enclosing_volume(). 999 * 1000 * Deprecated: use the #GtkPlacesSidebar::show-other-locations signal 1001 * to connect to network servers. 1002 */ 1003 gulong addOnShowConnectToServer(void delegate(PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1004 { 1005 auto wrapper = new OnShowConnectToServerDelegateWrapper(dlg); 1006 wrapper.handlerId = Signals.connectData( 1007 this, 1008 "show-connect-to-server", 1009 cast(GCallback)&callBackShowConnectToServer, 1010 cast(void*)wrapper, 1011 cast(GClosureNotify)&callBackShowConnectToServerDestroy, 1012 connectFlags); 1013 return wrapper.handlerId; 1014 } 1015 1016 extern(C) static void callBackShowConnectToServer(GtkPlacesSidebar* placessidebarStruct, OnShowConnectToServerDelegateWrapper wrapper) 1017 { 1018 wrapper.dlg(wrapper.outer); 1019 } 1020 1021 extern(C) static void callBackShowConnectToServerDestroy(OnShowConnectToServerDelegateWrapper wrapper, GClosure* closure) 1022 { 1023 wrapper.remove(wrapper); 1024 } 1025 1026 protected class OnShowEnterLocationDelegateWrapper 1027 { 1028 void delegate(PlacesSidebar) dlg; 1029 gulong handlerId; 1030 1031 this(void delegate(PlacesSidebar) dlg) 1032 { 1033 this.dlg = dlg; 1034 onShowEnterLocationListeners ~= this; 1035 } 1036 1037 void remove(OnShowEnterLocationDelegateWrapper source) 1038 { 1039 foreach(index, wrapper; onShowEnterLocationListeners) 1040 { 1041 if (wrapper.handlerId == source.handlerId) 1042 { 1043 onShowEnterLocationListeners[index] = null; 1044 onShowEnterLocationListeners = std.algorithm.remove(onShowEnterLocationListeners, index); 1045 break; 1046 } 1047 } 1048 } 1049 } 1050 OnShowEnterLocationDelegateWrapper[] onShowEnterLocationListeners; 1051 1052 /** 1053 * The places sidebar emits this signal when it needs the calling 1054 * application to present an way to directly enter a location. 1055 * For example, the application may bring up a dialog box asking for 1056 * a URL like "http://http.example.com". 1057 * 1058 * Since: 3.14 1059 */ 1060 gulong addOnShowEnterLocation(void delegate(PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1061 { 1062 auto wrapper = new OnShowEnterLocationDelegateWrapper(dlg); 1063 wrapper.handlerId = Signals.connectData( 1064 this, 1065 "show-enter-location", 1066 cast(GCallback)&callBackShowEnterLocation, 1067 cast(void*)wrapper, 1068 cast(GClosureNotify)&callBackShowEnterLocationDestroy, 1069 connectFlags); 1070 return wrapper.handlerId; 1071 } 1072 1073 extern(C) static void callBackShowEnterLocation(GtkPlacesSidebar* placessidebarStruct, OnShowEnterLocationDelegateWrapper wrapper) 1074 { 1075 wrapper.dlg(wrapper.outer); 1076 } 1077 1078 extern(C) static void callBackShowEnterLocationDestroy(OnShowEnterLocationDelegateWrapper wrapper, GClosure* closure) 1079 { 1080 wrapper.remove(wrapper); 1081 } 1082 1083 protected class OnShowErrorMessageDelegateWrapper 1084 { 1085 void delegate(string, string, PlacesSidebar) dlg; 1086 gulong handlerId; 1087 1088 this(void delegate(string, string, PlacesSidebar) dlg) 1089 { 1090 this.dlg = dlg; 1091 onShowErrorMessageListeners ~= this; 1092 } 1093 1094 void remove(OnShowErrorMessageDelegateWrapper source) 1095 { 1096 foreach(index, wrapper; onShowErrorMessageListeners) 1097 { 1098 if (wrapper.handlerId == source.handlerId) 1099 { 1100 onShowErrorMessageListeners[index] = null; 1101 onShowErrorMessageListeners = std.algorithm.remove(onShowErrorMessageListeners, index); 1102 break; 1103 } 1104 } 1105 } 1106 } 1107 OnShowErrorMessageDelegateWrapper[] onShowErrorMessageListeners; 1108 1109 /** 1110 * The places sidebar emits this signal when it needs the calling 1111 * application to present an error message. Most of these messages 1112 * refer to mounting or unmounting media, for example, when a drive 1113 * cannot be started for some reason. 1114 * 1115 * Params: 1116 * primary = primary message with a summary of the error to show. 1117 * secondary = secondary message with details of the error to show. 1118 * 1119 * Since: 3.10 1120 */ 1121 gulong addOnShowErrorMessage(void delegate(string, string, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1122 { 1123 auto wrapper = new OnShowErrorMessageDelegateWrapper(dlg); 1124 wrapper.handlerId = Signals.connectData( 1125 this, 1126 "show-error-message", 1127 cast(GCallback)&callBackShowErrorMessage, 1128 cast(void*)wrapper, 1129 cast(GClosureNotify)&callBackShowErrorMessageDestroy, 1130 connectFlags); 1131 return wrapper.handlerId; 1132 } 1133 1134 extern(C) static void callBackShowErrorMessage(GtkPlacesSidebar* placessidebarStruct, char* primary, char* secondary, OnShowErrorMessageDelegateWrapper wrapper) 1135 { 1136 wrapper.dlg(Str.toString(primary), Str.toString(secondary), wrapper.outer); 1137 } 1138 1139 extern(C) static void callBackShowErrorMessageDestroy(OnShowErrorMessageDelegateWrapper wrapper, GClosure* closure) 1140 { 1141 wrapper.remove(wrapper); 1142 } 1143 1144 protected class OnShowOtherLocationsDelegateWrapper 1145 { 1146 void delegate(PlacesSidebar) dlg; 1147 gulong handlerId; 1148 1149 this(void delegate(PlacesSidebar) dlg) 1150 { 1151 this.dlg = dlg; 1152 onShowOtherLocationsListeners ~= this; 1153 } 1154 1155 void remove(OnShowOtherLocationsDelegateWrapper source) 1156 { 1157 foreach(index, wrapper; onShowOtherLocationsListeners) 1158 { 1159 if (wrapper.handlerId == source.handlerId) 1160 { 1161 onShowOtherLocationsListeners[index] = null; 1162 onShowOtherLocationsListeners = std.algorithm.remove(onShowOtherLocationsListeners, index); 1163 break; 1164 } 1165 } 1166 } 1167 } 1168 OnShowOtherLocationsDelegateWrapper[] onShowOtherLocationsListeners; 1169 1170 /** 1171 * The places sidebar emits this signal when it needs the calling 1172 * application to present a way to show other locations e.g. drives 1173 * and network access points. 1174 * For example, the application may bring up a page showing persistent 1175 * volumes and discovered network addresses. 1176 * 1177 * Deprecated: use the #GtkPlacesSidebar::show-other-locations-with-flags 1178 * which includes the open flags in order to allow the user to specify to open 1179 * in a new tab or window, in a similar way than #GtkPlacesSidebar::open-location 1180 * 1181 * Since: 3.18 1182 */ 1183 gulong addOnShowOtherLocations(void delegate(PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1184 { 1185 auto wrapper = new OnShowOtherLocationsDelegateWrapper(dlg); 1186 wrapper.handlerId = Signals.connectData( 1187 this, 1188 "show-other-locations", 1189 cast(GCallback)&callBackShowOtherLocations, 1190 cast(void*)wrapper, 1191 cast(GClosureNotify)&callBackShowOtherLocationsDestroy, 1192 connectFlags); 1193 return wrapper.handlerId; 1194 } 1195 1196 extern(C) static void callBackShowOtherLocations(GtkPlacesSidebar* placessidebarStruct, OnShowOtherLocationsDelegateWrapper wrapper) 1197 { 1198 wrapper.dlg(wrapper.outer); 1199 } 1200 1201 extern(C) static void callBackShowOtherLocationsDestroy(OnShowOtherLocationsDelegateWrapper wrapper, GClosure* closure) 1202 { 1203 wrapper.remove(wrapper); 1204 } 1205 1206 protected class OnShowOtherLocationsWithFlagsDelegateWrapper 1207 { 1208 void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg; 1209 gulong handlerId; 1210 1211 this(void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg) 1212 { 1213 this.dlg = dlg; 1214 onShowOtherLocationsWithFlagsListeners ~= this; 1215 } 1216 1217 void remove(OnShowOtherLocationsWithFlagsDelegateWrapper source) 1218 { 1219 foreach(index, wrapper; onShowOtherLocationsWithFlagsListeners) 1220 { 1221 if (wrapper.handlerId == source.handlerId) 1222 { 1223 onShowOtherLocationsWithFlagsListeners[index] = null; 1224 onShowOtherLocationsWithFlagsListeners = std.algorithm.remove(onShowOtherLocationsWithFlagsListeners, index); 1225 break; 1226 } 1227 } 1228 } 1229 } 1230 OnShowOtherLocationsWithFlagsDelegateWrapper[] onShowOtherLocationsWithFlagsListeners; 1231 1232 /** 1233 * The places sidebar emits this signal when it needs the calling 1234 * application to present a way to show other locations e.g. drives 1235 * and network access points. 1236 * For example, the application may bring up a page showing persistent 1237 * volumes and discovered network addresses. 1238 * 1239 * Params: 1240 * openFlags = a single value from #GtkPlacesOpenFlags specifying how it should be opened. 1241 * 1242 * Since: 3.20 1243 */ 1244 gulong addOnShowOtherLocationsWithFlags(void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1245 { 1246 auto wrapper = new OnShowOtherLocationsWithFlagsDelegateWrapper(dlg); 1247 wrapper.handlerId = Signals.connectData( 1248 this, 1249 "show-other-locations-with-flags", 1250 cast(GCallback)&callBackShowOtherLocationsWithFlags, 1251 cast(void*)wrapper, 1252 cast(GClosureNotify)&callBackShowOtherLocationsWithFlagsDestroy, 1253 connectFlags); 1254 return wrapper.handlerId; 1255 } 1256 1257 extern(C) static void callBackShowOtherLocationsWithFlags(GtkPlacesSidebar* placessidebarStruct, GtkPlacesOpenFlags openFlags, OnShowOtherLocationsWithFlagsDelegateWrapper wrapper) 1258 { 1259 wrapper.dlg(openFlags, wrapper.outer); 1260 } 1261 1262 extern(C) static void callBackShowOtherLocationsWithFlagsDestroy(OnShowOtherLocationsWithFlagsDelegateWrapper wrapper, GClosure* closure) 1263 { 1264 wrapper.remove(wrapper); 1265 } 1266 1267 protected class OnShowStarredLocationDelegateWrapper 1268 { 1269 void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg; 1270 gulong handlerId; 1271 1272 this(void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg) 1273 { 1274 this.dlg = dlg; 1275 onShowStarredLocationListeners ~= this; 1276 } 1277 1278 void remove(OnShowStarredLocationDelegateWrapper source) 1279 { 1280 foreach(index, wrapper; onShowStarredLocationListeners) 1281 { 1282 if (wrapper.handlerId == source.handlerId) 1283 { 1284 onShowStarredLocationListeners[index] = null; 1285 onShowStarredLocationListeners = std.algorithm.remove(onShowStarredLocationListeners, index); 1286 break; 1287 } 1288 } 1289 } 1290 } 1291 OnShowStarredLocationDelegateWrapper[] onShowStarredLocationListeners; 1292 1293 /** 1294 * The places sidebar emits this signal when it needs the calling 1295 * application to present a way to show the starred files. In GNOME, 1296 * starred files are implemented by setting the nao:predefined-tag-favorite 1297 * tag in the tracker database. 1298 * 1299 * Since: 3.22.26 1300 */ 1301 gulong addOnShowStarredLocation(void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1302 { 1303 auto wrapper = new OnShowStarredLocationDelegateWrapper(dlg); 1304 wrapper.handlerId = Signals.connectData( 1305 this, 1306 "show-starred-location", 1307 cast(GCallback)&callBackShowStarredLocation, 1308 cast(void*)wrapper, 1309 cast(GClosureNotify)&callBackShowStarredLocationDestroy, 1310 connectFlags); 1311 return wrapper.handlerId; 1312 } 1313 1314 extern(C) static void callBackShowStarredLocation(GtkPlacesSidebar* placessidebarStruct, GtkPlacesOpenFlags object, OnShowStarredLocationDelegateWrapper wrapper) 1315 { 1316 wrapper.dlg(object, wrapper.outer); 1317 } 1318 1319 extern(C) static void callBackShowStarredLocationDestroy(OnShowStarredLocationDelegateWrapper wrapper, GClosure* closure) 1320 { 1321 wrapper.remove(wrapper); 1322 } 1323 1324 protected class OnUnmountDelegateWrapper 1325 { 1326 void delegate(MountOperation, PlacesSidebar) dlg; 1327 gulong handlerId; 1328 1329 this(void delegate(MountOperation, PlacesSidebar) dlg) 1330 { 1331 this.dlg = dlg; 1332 onUnmountListeners ~= this; 1333 } 1334 1335 void remove(OnUnmountDelegateWrapper source) 1336 { 1337 foreach(index, wrapper; onUnmountListeners) 1338 { 1339 if (wrapper.handlerId == source.handlerId) 1340 { 1341 onUnmountListeners[index] = null; 1342 onUnmountListeners = std.algorithm.remove(onUnmountListeners, index); 1343 break; 1344 } 1345 } 1346 } 1347 } 1348 OnUnmountDelegateWrapper[] onUnmountListeners; 1349 1350 /** 1351 * The places sidebar emits this signal when it starts a new operation 1352 * because the user for example ejected some drive or unmounted a mount. 1353 * In this way the application using the #GtkPlacesSidebar can track the 1354 * progress of the operation and, for example, show a notification. 1355 * 1356 * Params: 1357 * mountOperation = the #GMountOperation that is going to start. 1358 * 1359 * Since: 3.20 1360 */ 1361 gulong addOnUnmount(void delegate(MountOperation, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1362 { 1363 auto wrapper = new OnUnmountDelegateWrapper(dlg); 1364 wrapper.handlerId = Signals.connectData( 1365 this, 1366 "unmount", 1367 cast(GCallback)&callBackUnmount, 1368 cast(void*)wrapper, 1369 cast(GClosureNotify)&callBackUnmountDestroy, 1370 connectFlags); 1371 return wrapper.handlerId; 1372 } 1373 1374 extern(C) static void callBackUnmount(GtkPlacesSidebar* placessidebarStruct, GMountOperation* mountOperation, OnUnmountDelegateWrapper wrapper) 1375 { 1376 wrapper.dlg(ObjectG.getDObject!(MountOperation)(mountOperation), wrapper.outer); 1377 } 1378 1379 extern(C) static void callBackUnmountDestroy(OnUnmountDelegateWrapper wrapper, GClosure* closure) 1380 { 1381 wrapper.remove(wrapper); 1382 } 1383 }