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 public import gtkc.gdktypes; 42 private import gtkc.gtk; 43 public import gtkc.gtktypes; 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 placesidebar 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 * Return: 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 * Return: %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 * Return: 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 * Return: 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 * Return: 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 * Return: %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 * Return: %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 * Return: %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 * Return: %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 * Return: %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 * Return: %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 * Return: 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 int[string] connectedSignals; 542 543 int delegate(int, PlacesSidebar)[] onDragActionAskListeners; 544 /** 545 * The places sidebar emits this signal when it needs to ask the application 546 * to pop up a menu to ask the user for which drag action to perform. 547 * 548 * Params: 549 * actions = Possible drag actions that need to be asked for. 550 * 551 * Return: the final drag action that the sidebar should pass to the drag side 552 * of the drag-and-drop operation. 553 * 554 * Since: 3.10 555 */ 556 void addOnDragActionAsk(int delegate(int, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 557 { 558 if ( "drag-action-ask" !in connectedSignals ) 559 { 560 Signals.connectData( 561 this, 562 "drag-action-ask", 563 cast(GCallback)&callBackDragActionAsk, 564 cast(void*)this, 565 null, 566 connectFlags); 567 connectedSignals["drag-action-ask"] = 1; 568 } 569 onDragActionAskListeners ~= dlg; 570 } 571 extern(C) static int callBackDragActionAsk(GtkPlacesSidebar* placessidebarStruct, int actions, PlacesSidebar _placessidebar) 572 { 573 return _placessidebar.onDragActionAskListeners[0](actions, _placessidebar); 574 } 575 576 int delegate(DragContext, FileIF, ListG, PlacesSidebar)[] onDragActionRequestedListeners; 577 /** 578 * When the user starts a drag-and-drop operation and the sidebar needs 579 * to ask the application for which drag action to perform, then the 580 * sidebar will emit this signal. 581 * 582 * The application can evaluate the @context for customary actions, or 583 * it can check the type of the files indicated by @source_file_list against the 584 * possible actions for the destination @dest_file. 585 * 586 * The drag action to use must be the return value of the signal handler. 587 * 588 * Params: 589 * context = #GdkDragContext with information about the drag operation 590 * destFile = #GFile with the tentative location that is being hovered for a drop 591 * sourceFileList = List of #GFile that are being dragged 592 * 593 * Return: The drag action to use, for example, #GDK_ACTION_COPY 594 * or #GDK_ACTION_MOVE, or 0 if no action is allowed here (i.e. drops 595 * are not allowed in the specified @dest_file). 596 * 597 * Since: 3.10 598 */ 599 void addOnDragActionRequested(int delegate(DragContext, FileIF, ListG, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 600 { 601 if ( "drag-action-requested" !in connectedSignals ) 602 { 603 Signals.connectData( 604 this, 605 "drag-action-requested", 606 cast(GCallback)&callBackDragActionRequested, 607 cast(void*)this, 608 null, 609 connectFlags); 610 connectedSignals["drag-action-requested"] = 1; 611 } 612 onDragActionRequestedListeners ~= dlg; 613 } 614 extern(C) static int callBackDragActionRequested(GtkPlacesSidebar* placessidebarStruct, GdkDragContext* context, GFile* destFile, GList* sourceFileList, PlacesSidebar _placessidebar) 615 { 616 return _placessidebar.onDragActionRequestedListeners[0](ObjectG.getDObject!(DragContext)(context), ObjectG.getDObject!(File, FileIF)(destFile), new ListG(sourceFileList), _placessidebar); 617 } 618 619 void delegate(FileIF, ListG, int, PlacesSidebar)[] onDragPerformDropListeners; 620 /** 621 * The places sidebar emits this signal when the user completes a 622 * drag-and-drop operation and one of the sidebar's items is the 623 * destination. This item is in the @dest_file, and the 624 * @source_file_list has the list of files that are dropped into it and 625 * which should be copied/moved/etc. based on the specified @action. 626 * 627 * Params: 628 * destFile = Destination #GFile. 629 * sourceFileList = #GList of #GFile that got dropped. 630 * action = Drop action to perform. 631 * 632 * Since: 3.10 633 */ 634 void addOnDragPerformDrop(void delegate(FileIF, ListG, int, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 635 { 636 if ( "drag-perform-drop" !in connectedSignals ) 637 { 638 Signals.connectData( 639 this, 640 "drag-perform-drop", 641 cast(GCallback)&callBackDragPerformDrop, 642 cast(void*)this, 643 null, 644 connectFlags); 645 connectedSignals["drag-perform-drop"] = 1; 646 } 647 onDragPerformDropListeners ~= dlg; 648 } 649 extern(C) static void callBackDragPerformDrop(GtkPlacesSidebar* placessidebarStruct, GFile* destFile, GList* sourceFileList, int action, PlacesSidebar _placessidebar) 650 { 651 foreach ( void delegate(FileIF, ListG, int, PlacesSidebar) dlg; _placessidebar.onDragPerformDropListeners ) 652 { 653 dlg(ObjectG.getDObject!(File, FileIF)(destFile), new ListG(sourceFileList), action, _placessidebar); 654 } 655 } 656 657 void delegate(MountOperation, PlacesSidebar)[] onMountListeners; 658 /** 659 * The places sidebar emits this signal when it starts a new operation 660 * because the user clicked on some location that needs mounting. 661 * In this way the application using the #GtkPlacesSidebar can track the 662 * progress of the operation and, for example, show a notification. 663 * 664 * Params: 665 * mountOperation = the #GMountOperation that is going to start. 666 * 667 * Since: 3.20 668 */ 669 void addOnMount(void delegate(MountOperation, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 670 { 671 if ( "mount" !in connectedSignals ) 672 { 673 Signals.connectData( 674 this, 675 "mount", 676 cast(GCallback)&callBackMount, 677 cast(void*)this, 678 null, 679 connectFlags); 680 connectedSignals["mount"] = 1; 681 } 682 onMountListeners ~= dlg; 683 } 684 extern(C) static void callBackMount(GtkPlacesSidebar* placessidebarStruct, GMountOperation* mountOperation, PlacesSidebar _placessidebar) 685 { 686 foreach ( void delegate(MountOperation, PlacesSidebar) dlg; _placessidebar.onMountListeners ) 687 { 688 dlg(ObjectG.getDObject!(MountOperation)(mountOperation), _placessidebar); 689 } 690 } 691 692 void delegate(FileIF, GtkPlacesOpenFlags, PlacesSidebar)[] onOpenLocationListeners; 693 /** 694 * The places sidebar emits this signal when the user selects a location 695 * in it. The calling application should display the contents of that 696 * location; for example, a file manager should show a list of files in 697 * the specified location. 698 * 699 * Params: 700 * location = #GFile to which the caller should switch. 701 * openFlags = a single value from #GtkPlacesOpenFlags specifying how the @location should be opened. 702 * 703 * Since: 3.10 704 */ 705 void addOnOpenLocation(void delegate(FileIF, GtkPlacesOpenFlags, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 706 { 707 if ( "open-location" !in connectedSignals ) 708 { 709 Signals.connectData( 710 this, 711 "open-location", 712 cast(GCallback)&callBackOpenLocation, 713 cast(void*)this, 714 null, 715 connectFlags); 716 connectedSignals["open-location"] = 1; 717 } 718 onOpenLocationListeners ~= dlg; 719 } 720 extern(C) static void callBackOpenLocation(GtkPlacesSidebar* placessidebarStruct, GFile* location, GtkPlacesOpenFlags openFlags, PlacesSidebar _placessidebar) 721 { 722 foreach ( void delegate(FileIF, GtkPlacesOpenFlags, PlacesSidebar) dlg; _placessidebar.onOpenLocationListeners ) 723 { 724 dlg(ObjectG.getDObject!(File, FileIF)(location), openFlags, _placessidebar); 725 } 726 } 727 728 void delegate(Widget, FileIF, VolumeIF, PlacesSidebar)[] onPopulatePopupListeners; 729 /** 730 * The places sidebar emits this signal when the user invokes a contextual 731 * popup on one of its items. In the signal handler, the application may 732 * add extra items to the menu as appropriate. For example, a file manager 733 * may want to add a "Properties" command to the menu. 734 * 735 * It is not necessary to store the @selected_item for each menu item; 736 * during their callbacks, the application can use gtk_places_sidebar_get_location() 737 * to get the file to which the item refers. 738 * 739 * The @selected_item argument may be %NULL in case the selection refers to 740 * a volume. In this case, @selected_volume will be non-%NULL. In this case, 741 * the calling application will have to g_object_ref() the @selected_volume and 742 * keep it around to use it in the callback. 743 * 744 * The @container and all its contents are destroyed after the user 745 * dismisses the popup. The popup is re-created (and thus, this signal is 746 * emitted) every time the user activates the contextual menu. 747 * 748 * Before 3.18, the @container always was a #GtkMenu, and you were expected 749 * to add your items as #GtkMenuItems. Since 3.18, the popup may be implemented 750 * as a #GtkPopover, in which case @container will be something else, e.g. a 751 * #GtkBox, to which you may add #GtkModelButtons or other widgets, such as 752 * #GtkEntries, #GtkSpinButtons, etc. If your application can deal with this 753 * situation, you can set #GtkPlacesSidebar::populate-all to %TRUE to request 754 * that this signal is emitted for populating popovers as well. 755 * 756 * Params: 757 * container = a #GtkMenu or another #GtkContainer 758 * selectedItem = #GFile with the item to which the popup should refer, or #NULL in the case of a @selected_volume. 759 * selectedVolume = #GVolume if the selected item is a volume, or #NULL if it is a file. 760 * 761 * Since: 3.10 762 */ 763 void addOnPopulatePopup(void delegate(Widget, FileIF, VolumeIF, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 764 { 765 if ( "populate-popup" !in connectedSignals ) 766 { 767 Signals.connectData( 768 this, 769 "populate-popup", 770 cast(GCallback)&callBackPopulatePopup, 771 cast(void*)this, 772 null, 773 connectFlags); 774 connectedSignals["populate-popup"] = 1; 775 } 776 onPopulatePopupListeners ~= dlg; 777 } 778 extern(C) static void callBackPopulatePopup(GtkPlacesSidebar* placessidebarStruct, GtkWidget* container, GFile* selectedItem, GVolume* selectedVolume, PlacesSidebar _placessidebar) 779 { 780 foreach ( void delegate(Widget, FileIF, VolumeIF, PlacesSidebar) dlg; _placessidebar.onPopulatePopupListeners ) 781 { 782 dlg(ObjectG.getDObject!(Widget)(container), ObjectG.getDObject!(File, FileIF)(selectedItem), ObjectG.getDObject!(Volume, VolumeIF)(selectedVolume), _placessidebar); 783 } 784 } 785 786 void delegate(PlacesSidebar)[] onShowConnectToServerListeners; 787 /** 788 * The places sidebar emits this signal when it needs the calling 789 * application to present an way to connect directly to a network server. 790 * For example, the application may bring up a dialog box asking for 791 * a URL like "sftp://ftp.example.com". It is up to the application to create 792 * the corresponding mount by using, for example, g_file_mount_enclosing_volume(). 793 * 794 * Deprecated: use the #GtkPlacesSidebar::show-other-locations signal 795 * to connect to network servers. 796 */ 797 void addOnShowConnectToServer(void delegate(PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 798 { 799 if ( "show-connect-to-server" !in connectedSignals ) 800 { 801 Signals.connectData( 802 this, 803 "show-connect-to-server", 804 cast(GCallback)&callBackShowConnectToServer, 805 cast(void*)this, 806 null, 807 connectFlags); 808 connectedSignals["show-connect-to-server"] = 1; 809 } 810 onShowConnectToServerListeners ~= dlg; 811 } 812 extern(C) static void callBackShowConnectToServer(GtkPlacesSidebar* placessidebarStruct, PlacesSidebar _placessidebar) 813 { 814 foreach ( void delegate(PlacesSidebar) dlg; _placessidebar.onShowConnectToServerListeners ) 815 { 816 dlg(_placessidebar); 817 } 818 } 819 820 void delegate(PlacesSidebar)[] onShowEnterLocationListeners; 821 /** 822 * The places sidebar emits this signal when it needs the calling 823 * application to present an way to directly enter a location. 824 * For example, the application may bring up a dialog box asking for 825 * a URL like "http://http.example.com". 826 * 827 * Since: 3.14 828 */ 829 void addOnShowEnterLocation(void delegate(PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 830 { 831 if ( "show-enter-location" !in connectedSignals ) 832 { 833 Signals.connectData( 834 this, 835 "show-enter-location", 836 cast(GCallback)&callBackShowEnterLocation, 837 cast(void*)this, 838 null, 839 connectFlags); 840 connectedSignals["show-enter-location"] = 1; 841 } 842 onShowEnterLocationListeners ~= dlg; 843 } 844 extern(C) static void callBackShowEnterLocation(GtkPlacesSidebar* placessidebarStruct, PlacesSidebar _placessidebar) 845 { 846 foreach ( void delegate(PlacesSidebar) dlg; _placessidebar.onShowEnterLocationListeners ) 847 { 848 dlg(_placessidebar); 849 } 850 } 851 852 void delegate(string, string, PlacesSidebar)[] onShowErrorMessageListeners; 853 /** 854 * The places sidebar emits this signal when it needs the calling 855 * application to present an error message. Most of these messages 856 * refer to mounting or unmounting media, for example, when a drive 857 * cannot be started for some reason. 858 * 859 * Params: 860 * primary = primary message with a summary of the error to show. 861 * secondary = secondary message with details of the error to show. 862 * 863 * Since: 3.10 864 */ 865 void addOnShowErrorMessage(void delegate(string, string, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 866 { 867 if ( "show-error-message" !in connectedSignals ) 868 { 869 Signals.connectData( 870 this, 871 "show-error-message", 872 cast(GCallback)&callBackShowErrorMessage, 873 cast(void*)this, 874 null, 875 connectFlags); 876 connectedSignals["show-error-message"] = 1; 877 } 878 onShowErrorMessageListeners ~= dlg; 879 } 880 extern(C) static void callBackShowErrorMessage(GtkPlacesSidebar* placessidebarStruct, char* primary, char* secondary, PlacesSidebar _placessidebar) 881 { 882 foreach ( void delegate(string, string, PlacesSidebar) dlg; _placessidebar.onShowErrorMessageListeners ) 883 { 884 dlg(Str.toString(primary), Str.toString(secondary), _placessidebar); 885 } 886 } 887 888 void delegate(PlacesSidebar)[] onShowOtherLocationsListeners; 889 /** 890 * The places sidebar emits this signal when it needs the calling 891 * application to present a way to show other locations e.g. drives 892 * and network access points. 893 * For example, the application may bring up a page showing persistent 894 * volumes and discovered network addresses. 895 * 896 * Deprecated: use the #GtkPlacesSidebar::show-other-locations-with-flags 897 * which includes the open flags in order to allow the user to specify to open 898 * in a new tab or window, in a similar way than #GtkPlacesSidebar::open-location 899 * 900 * Since: 3.18 901 */ 902 void addOnShowOtherLocations(void delegate(PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 903 { 904 if ( "show-other-locations" !in connectedSignals ) 905 { 906 Signals.connectData( 907 this, 908 "show-other-locations", 909 cast(GCallback)&callBackShowOtherLocations, 910 cast(void*)this, 911 null, 912 connectFlags); 913 connectedSignals["show-other-locations"] = 1; 914 } 915 onShowOtherLocationsListeners ~= dlg; 916 } 917 extern(C) static void callBackShowOtherLocations(GtkPlacesSidebar* placessidebarStruct, PlacesSidebar _placessidebar) 918 { 919 foreach ( void delegate(PlacesSidebar) dlg; _placessidebar.onShowOtherLocationsListeners ) 920 { 921 dlg(_placessidebar); 922 } 923 } 924 925 void delegate(GtkPlacesOpenFlags, PlacesSidebar)[] onShowOtherLocationsWithFlagsListeners; 926 /** 927 * The places sidebar emits this signal when it needs the calling 928 * application to present a way to show other locations e.g. drives 929 * and network access points. 930 * For example, the application may bring up a page showing persistent 931 * volumes and discovered network addresses. 932 * 933 * Params: 934 * openFlags = a single value from #GtkPlacesOpenFlags specifying how it should be opened. 935 * 936 * Since: 3.20 937 */ 938 void addOnShowOtherLocationsWithFlags(void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 939 { 940 if ( "show-other-locations-with-flags" !in connectedSignals ) 941 { 942 Signals.connectData( 943 this, 944 "show-other-locations-with-flags", 945 cast(GCallback)&callBackShowOtherLocationsWithFlags, 946 cast(void*)this, 947 null, 948 connectFlags); 949 connectedSignals["show-other-locations-with-flags"] = 1; 950 } 951 onShowOtherLocationsWithFlagsListeners ~= dlg; 952 } 953 extern(C) static void callBackShowOtherLocationsWithFlags(GtkPlacesSidebar* placessidebarStruct, GtkPlacesOpenFlags openFlags, PlacesSidebar _placessidebar) 954 { 955 foreach ( void delegate(GtkPlacesOpenFlags, PlacesSidebar) dlg; _placessidebar.onShowOtherLocationsWithFlagsListeners ) 956 { 957 dlg(openFlags, _placessidebar); 958 } 959 } 960 961 void delegate(MountOperation, PlacesSidebar)[] onUnmountListeners; 962 /** 963 * The places sidebar emits this signal when it starts a new operation 964 * because the user for example ejected some drive or unmounted a mount. 965 * In this way the application using the #GtkPlacesSidebar can track the 966 * progress of the operation and, for example, show a notification. 967 * 968 * Params: 969 * mountOperation = the #GMountOperation that is going to start. 970 * 971 * Since: 3.20 972 */ 973 void addOnUnmount(void delegate(MountOperation, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 974 { 975 if ( "unmount" !in connectedSignals ) 976 { 977 Signals.connectData( 978 this, 979 "unmount", 980 cast(GCallback)&callBackUnmount, 981 cast(void*)this, 982 null, 983 connectFlags); 984 connectedSignals["unmount"] = 1; 985 } 986 onUnmountListeners ~= dlg; 987 } 988 extern(C) static void callBackUnmount(GtkPlacesSidebar* placessidebarStruct, GMountOperation* mountOperation, PlacesSidebar _placessidebar) 989 { 990 foreach ( void delegate(MountOperation, PlacesSidebar) dlg; _placessidebar.onUnmountListeners ) 991 { 992 dlg(ObjectG.getDObject!(MountOperation)(mountOperation), _placessidebar); 993 } 994 } 995 }