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