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