1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GtkPlacesSidebar.html 27 * outPack = gtk 28 * outFile = PlacesSidebar 29 * strct = GtkPlacesSidebar 30 * realStrct= 31 * ctorStrct= 32 * clss = PlacesSidebar 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_places_sidebar_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ListSG 48 * - gio.File 49 * - gobject.ObjectG 50 * - gdk.DragContext 51 * structWrap: 52 * - GFile* -> File 53 * - GObject* -> ObjectG 54 * - GSList* -> ListSG 55 * - GdkDragContext* -> DragContext 56 * module aliases: 57 * local aliases: 58 * overrides: 59 */ 60 61 module gtk.PlacesSidebar; 62 63 public import gtkc.gtktypes; 64 65 private import gtkc.gtk; 66 private import glib.ConstructionException; 67 private import gobject.ObjectG; 68 69 private import gobject.Signals; 70 public import gtkc.gdktypes; 71 72 private import glib.Str; 73 private import glib.ListSG; 74 private import gio.File; 75 private import gobject.ObjectG; 76 private import gdk.DragContext; 77 78 79 80 private import gtk.ScrolledWindow; 81 82 /** 83 * GtkPlacesSidebar is a widget that displays a list of frequently-used places in the 84 * file system: the user's home directory, the user's bookmarks, and volumes and drives. 85 * This widget is used as a sidebar in GtkFileChooser and may be used by file managers 86 * and similar programs. 87 * 88 * The places sidebar displays drives and volumes, and will automatically mount 89 * or unmount them when the user selects them. 90 * 91 * Applications can hook to various signals in the places sidebar to customize 92 * its behavior. For example, they can add extra commands to the context menu 93 * of the sidebar. 94 * 95 * While bookmarks are completely in control of the user, the places sidebar also 96 * allows individual applications to provide extra shortcut folders that are unique 97 * to each application. For example, a Paint program may want to add a shortcut 98 * for a Clipart folder. You can do this with gtk_places_sidebar_add_shortcut(). 99 * 100 * To make use of the places sidebar, an application at least needs to connect 101 * to the "open-location" signal. This is emitted when the 102 * user selects in the sidebar a location to open. The application should also 103 * call gtk_places_sidebar_set_location() when it changes the currently-viewed 104 * location. 105 */ 106 public class PlacesSidebar : ScrolledWindow 107 { 108 109 /** the main Gtk struct */ 110 protected GtkPlacesSidebar* gtkPlacesSidebar; 111 112 113 public GtkPlacesSidebar* getPlacesSidebarStruct() 114 { 115 return gtkPlacesSidebar; 116 } 117 118 119 /** the main Gtk struct as a void* */ 120 protected override void* getStruct() 121 { 122 return cast(void*)gtkPlacesSidebar; 123 } 124 125 /** 126 * Sets our main struct and passes it to the parent class 127 */ 128 public this (GtkPlacesSidebar* gtkPlacesSidebar) 129 { 130 super(cast(GtkScrolledWindow*)gtkPlacesSidebar); 131 this.gtkPlacesSidebar = gtkPlacesSidebar; 132 } 133 134 protected override void setStruct(GObject* obj) 135 { 136 super.setStruct(obj); 137 gtkPlacesSidebar = cast(GtkPlacesSidebar*)obj; 138 } 139 140 /** 141 */ 142 int[string] connectedSignals; 143 144 gint delegate(gint, PlacesSidebar)[] onDragActionAskListeners; 145 /** 146 * The places sidebar emits this signal when it needs to ask the application 147 * to pop up a menu to ask the user for which drag action to perform. 148 * Since 3.10 149 */ 150 void addOnDragActionAsk(gint delegate(gint, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 151 { 152 if ( !("drag-action-ask" in connectedSignals) ) 153 { 154 Signals.connectData( 155 getStruct(), 156 "drag-action-ask", 157 cast(GCallback)&callBackDragActionAsk, 158 cast(void*)this, 159 null, 160 connectFlags); 161 connectedSignals["drag-action-ask"] = 1; 162 } 163 onDragActionAskListeners ~= dlg; 164 } 165 extern(C) static void callBackDragActionAsk(GtkPlacesSidebar* sidebarStruct, gint actions, PlacesSidebar _placesSidebar) 166 { 167 foreach ( gint delegate(gint, PlacesSidebar) dlg ; _placesSidebar.onDragActionAskListeners ) 168 { 169 dlg(actions, _placesSidebar); 170 } 171 } 172 173 gint delegate(DragContext, ObjectG, void*, PlacesSidebar)[] onDragActionRequestedListeners; 174 /** 175 * When the user starts a drag-and-drop operation and the sidebar needs 176 * to ask the application for which drag action to perform, then the 177 * sidebar will emit this signal. 178 * The application can evaluate the context for customary actions, or 179 * it can check the type of the files indicated by source_file_list against the 180 * possible actions for the destination dest_file. 181 * The drag action to use must be the return value of the signal handler. 182 * GdkDragContext with information about the drag operation 183 * GFile with the tentative location that is being hovered for a drop 184 * Since 3.10 185 */ 186 void addOnDragActionRequested(gint delegate(DragContext, ObjectG, void*, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 187 { 188 if ( !("drag-action-requested" in connectedSignals) ) 189 { 190 Signals.connectData( 191 getStruct(), 192 "drag-action-requested", 193 cast(GCallback)&callBackDragActionRequested, 194 cast(void*)this, 195 null, 196 connectFlags); 197 connectedSignals["drag-action-requested"] = 1; 198 } 199 onDragActionRequestedListeners ~= dlg; 200 } 201 extern(C) static void callBackDragActionRequested(GtkPlacesSidebar* sidebarStruct, GdkDragContext* context, GObject* destFile, void* sourceFileList, PlacesSidebar _placesSidebar) 202 { 203 foreach ( gint delegate(DragContext, ObjectG, void*, PlacesSidebar) dlg ; _placesSidebar.onDragActionRequestedListeners ) 204 { 205 dlg(ObjectG.getDObject!(DragContext)(context), ObjectG.getDObject!(ObjectG)(destFile), sourceFileList, _placesSidebar); 206 } 207 } 208 209 void delegate(ObjectG, void*, gint, PlacesSidebar)[] onDragPerformDropListeners; 210 /** 211 * The places sidebar emits this signal when the user completes a 212 * drag-and-drop operation and one of the sidebar's items is the 213 * destination. This item is in the dest_file, and the 214 * source_file_list has the list of files that are dropped into it and 215 * which should be copied/moved/etc. based on the specified action. 216 * GList of GFile that got dropped. [element-type GFile][transfer none] 217 * Since 3.10 218 */ 219 void addOnDragPerformDrop(void delegate(ObjectG, void*, gint, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 220 { 221 if ( !("drag-perform-drop" in connectedSignals) ) 222 { 223 Signals.connectData( 224 getStruct(), 225 "drag-perform-drop", 226 cast(GCallback)&callBackDragPerformDrop, 227 cast(void*)this, 228 null, 229 connectFlags); 230 connectedSignals["drag-perform-drop"] = 1; 231 } 232 onDragPerformDropListeners ~= dlg; 233 } 234 extern(C) static void callBackDragPerformDrop(GtkPlacesSidebar* sidebarStruct, GObject* destFile, void* sourceFileList, gint action, PlacesSidebar _placesSidebar) 235 { 236 foreach ( void delegate(ObjectG, void*, gint, PlacesSidebar) dlg ; _placesSidebar.onDragPerformDropListeners ) 237 { 238 dlg(ObjectG.getDObject!(ObjectG)(destFile), sourceFileList, action, _placesSidebar); 239 } 240 } 241 242 void delegate(ObjectG, GtkPlacesOpenFlags, PlacesSidebar)[] onOpenLocationListeners; 243 /** 244 * The places sidebar emits this signal when the user selects a location 245 * in it. The calling application should display the contents of that 246 * location; for example, a file manager should show a list of files in 247 * the specified location. 248 * GFile to which the caller should switch. 249 * Since 3.10 250 */ 251 void addOnOpenLocation(void delegate(ObjectG, GtkPlacesOpenFlags, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 252 { 253 if ( !("open-location" in connectedSignals) ) 254 { 255 Signals.connectData( 256 getStruct(), 257 "open-location", 258 cast(GCallback)&callBackOpenLocation, 259 cast(void*)this, 260 null, 261 connectFlags); 262 connectedSignals["open-location"] = 1; 263 } 264 onOpenLocationListeners ~= dlg; 265 } 266 extern(C) static void callBackOpenLocation(GtkPlacesSidebar* sidebarStruct, GObject* location, GtkPlacesOpenFlags openFlags, PlacesSidebar _placesSidebar) 267 { 268 foreach ( void delegate(ObjectG, GtkPlacesOpenFlags, PlacesSidebar) dlg ; _placesSidebar.onOpenLocationListeners ) 269 { 270 dlg(ObjectG.getDObject!(ObjectG)(location), openFlags, _placesSidebar); 271 } 272 } 273 274 void delegate(ObjectG, ObjectG, ObjectG, PlacesSidebar)[] onPopulatePopupListeners; 275 /** 276 * The places sidebar emits this signal when the user invokes a contextual 277 * menu on one of its items. In the signal handler, the application may 278 * add extra items to the menu as appropriate. For example, a file manager 279 * may want to add a "Properties" command to the menu. 280 * It is not necessary to store the selected_item for each menu item; 281 * during their GtkMenuItem::activate callbacks, the application can use 282 * gtk_places_sidebar_get_location() to get the file to which the item 283 * refers. 284 * The selected_item argument may be NULL in case the selection refers to 285 * a volume. In this case, selected_volume will be non-NULL. In this case, 286 * the calling application will have to g_object_ref() the selected_volume and 287 * keep it around for the purposes of its menu item's "activate" callback. 288 * The menu and all its menu items are destroyed after the user 289 * dismisses the menu. The menu is re-created (and thus, this signal is 290 * emitted) every time the user activates the contextual menu. 291 * GFile with the item to which the menu should refer, or NULL in the case of a selected_volume. 292 * GVolume if the selected item is a volume, or NULL if it is a file. 293 * Since 3.10 294 */ 295 void addOnPopulatePopup(void delegate(ObjectG, ObjectG, ObjectG, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 296 { 297 if ( !("populate-popup" in connectedSignals) ) 298 { 299 Signals.connectData( 300 getStruct(), 301 "populate-popup", 302 cast(GCallback)&callBackPopulatePopup, 303 cast(void*)this, 304 null, 305 connectFlags); 306 connectedSignals["populate-popup"] = 1; 307 } 308 onPopulatePopupListeners ~= dlg; 309 } 310 extern(C) static void callBackPopulatePopup(GtkPlacesSidebar* sidebarStruct, GObject* menu, GObject* selectedItem, GObject* selectedVolume, PlacesSidebar _placesSidebar) 311 { 312 foreach ( void delegate(ObjectG, ObjectG, ObjectG, PlacesSidebar) dlg ; _placesSidebar.onPopulatePopupListeners ) 313 { 314 dlg(ObjectG.getDObject!(ObjectG)(menu), ObjectG.getDObject!(ObjectG)(selectedItem), ObjectG.getDObject!(ObjectG)(selectedVolume), _placesSidebar); 315 } 316 } 317 318 void delegate(PlacesSidebar)[] onShowConnectToServerListeners; 319 /** 320 * The places sidebar emits this signal when it needs the calling 321 * application to present an way to connect directly to a network server. 322 * For example, the application may bring up a dialog box asking for 323 * a URL like "sftp://ftp.example.com". It is up to the application to create 324 * the corresponding mount by using, for example, g_file_mount_enclosing_volume(). 325 * Since 3.10 326 */ 327 void addOnShowConnectToServer(void delegate(PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 328 { 329 if ( !("show-connect-to-server" in connectedSignals) ) 330 { 331 Signals.connectData( 332 getStruct(), 333 "show-connect-to-server", 334 cast(GCallback)&callBackShowConnectToServer, 335 cast(void*)this, 336 null, 337 connectFlags); 338 connectedSignals["show-connect-to-server"] = 1; 339 } 340 onShowConnectToServerListeners ~= dlg; 341 } 342 extern(C) static void callBackShowConnectToServer(GtkPlacesSidebar* sidebarStruct, PlacesSidebar _placesSidebar) 343 { 344 foreach ( void delegate(PlacesSidebar) dlg ; _placesSidebar.onShowConnectToServerListeners ) 345 { 346 dlg(_placesSidebar); 347 } 348 } 349 350 void delegate(string, string, PlacesSidebar)[] onShowErrorMessageListeners; 351 /** 352 * The places sidebar emits this signal when it needs the calling 353 * application to present an error message. Most of these messages 354 * refer to mounting or unmounting media, for example, when a drive 355 * cannot be started for some reason. 356 * Since 3.10 357 * See Also 358 * GtkFileChooser 359 */ 360 void addOnShowErrorMessage(void delegate(string, string, PlacesSidebar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 361 { 362 if ( !("show-error-message" in connectedSignals) ) 363 { 364 Signals.connectData( 365 getStruct(), 366 "show-error-message", 367 cast(GCallback)&callBackShowErrorMessage, 368 cast(void*)this, 369 null, 370 connectFlags); 371 connectedSignals["show-error-message"] = 1; 372 } 373 onShowErrorMessageListeners ~= dlg; 374 } 375 extern(C) static void callBackShowErrorMessage(GtkPlacesSidebar* sidebarStruct, gchar* primary, gchar* secondary, PlacesSidebar _placesSidebar) 376 { 377 foreach ( void delegate(string, string, PlacesSidebar) dlg ; _placesSidebar.onShowErrorMessageListeners ) 378 { 379 dlg(Str.toString(primary), Str.toString(secondary), _placesSidebar); 380 } 381 } 382 383 384 /** 385 * Creates a new GtkPlacesSidebar widget. 386 * The application should connect to at least the 387 * "open-location" signal to be notified 388 * when the user makes a selection in the sidebar. 389 * Throws: ConstructionException GTK+ fails to create the object. 390 */ 391 public this () 392 { 393 // GtkWidget * gtk_places_sidebar_new (void); 394 auto p = gtk_places_sidebar_new(); 395 if(p is null) 396 { 397 throw new ConstructionException("null returned by gtk_places_sidebar_new()"); 398 } 399 this(cast(GtkPlacesSidebar*) p); 400 } 401 402 /** 403 * Sets the way in which the calling application can open new locations from 404 * the places sidebar. For example, some applications only open locations 405 * "directly" into their main view, while others may support opening locations 406 * in a new notebook tab or a new window. 407 * This function is used to tell the places sidebar about the ways in which the 408 * application can open new locations, so that the sidebar can display (or not) 409 * the "Open in new tab" and "Open in new window" menu items as appropriate. 410 * When the "open-location" signal is emitted, its flags 411 * argument will be set to one of the flags that was passed in 412 * gtk_places_sidebar_set_open_flags(). 413 * Passing 0 for flags will cause GTK_PLACES_OPEN_NORMAL to always be sent 414 * to callbacks for the "open-location" signal. 415 * Params: 416 * flags = Bitmask of modes in which the calling application can open locations 417 * Since 3.10 418 */ 419 public void setOpenFlags(GtkPlacesOpenFlags flags) 420 { 421 // void gtk_places_sidebar_set_open_flags (GtkPlacesSidebar *sidebar, GtkPlacesOpenFlags flags); 422 gtk_places_sidebar_set_open_flags(gtkPlacesSidebar, flags); 423 } 424 425 /** 426 * Gets the open flags. 427 * Returns: the GtkPlacesOpenFlags of sidebar Since 3.10 428 */ 429 public GtkPlacesOpenFlags getOpenFlags() 430 { 431 // GtkPlacesOpenFlags gtk_places_sidebar_get_open_flags (GtkPlacesSidebar *sidebar); 432 return gtk_places_sidebar_get_open_flags(gtkPlacesSidebar); 433 } 434 435 /** 436 * Sets the location that is being shown in the widgets surrounding the 437 * sidebar, for example, in a folder view in a file manager. In turn, the 438 * sidebar will highlight that location if it is being shown in the list of 439 * places, or it will unhighlight everything if the location is not among the 440 * places in the list. 441 * Params: 442 * location = location to select, or NULL for no current path. [allow-none] 443 * Since 3.10 444 */ 445 public void setLocation(File location) 446 { 447 // void gtk_places_sidebar_set_location (GtkPlacesSidebar *sidebar, GFile *location); 448 gtk_places_sidebar_set_location(gtkPlacesSidebar, (location is null) ? null : location.getFileStruct()); 449 } 450 451 /** 452 * Gets the currently-selected location in the sidebar. This can be NULL when 453 * nothing is selected, for example, when gtk_places_sidebar_set_location() has 454 * been called with a location that is not among the sidebar's list of places to 455 * show. 456 * You can use this function to get the selection in the sidebar. Also, if you 457 * connect to the "popup-menu" signal, you can use this 458 * function to get the location that is being referred to during the callbacks 459 * for your menu items. 460 * Returns: a GFile with the selected location, or NULL if nothing is visually selected. [transfer full] Since 3.10 461 */ 462 public File getLocation() 463 { 464 // GFile * gtk_places_sidebar_get_location (GtkPlacesSidebar *sidebar); 465 auto p = gtk_places_sidebar_get_location(gtkPlacesSidebar); 466 467 if(p is null) 468 { 469 return null; 470 } 471 472 return ObjectG.getDObject!(File)(cast(GFile*) p); 473 } 474 475 /** 476 * Sets whether the sidebar should show an item for the Desktop folder; this is off by default. 477 * An application may want to turn this on if the desktop environment actually supports the 478 * notion of a desktop. 479 * Params: 480 * showDesktop = whether to show an item for the Desktop folder 481 * Since 3.10 482 */ 483 public void setShowDesktop(int showDesktop) 484 { 485 // void gtk_places_sidebar_set_show_desktop (GtkPlacesSidebar *sidebar, gboolean show_desktop); 486 gtk_places_sidebar_set_show_desktop(gtkPlacesSidebar, showDesktop); 487 } 488 489 /** 490 * Returns the value previously set with gtk_places_sidebar_set_show_desktop() 491 * Returns: TRUE if the sidebar will display a builtin shortcut to the desktop folder. Since 3.10 492 */ 493 public int getShowDesktop() 494 { 495 // gboolean gtk_places_sidebar_get_show_desktop (GtkPlacesSidebar *sidebar); 496 return gtk_places_sidebar_get_show_desktop(gtkPlacesSidebar); 497 } 498 499 /** 500 * Applications may want to present some folders in the places sidebar if 501 * they could be immediately useful to users. For example, a drawing 502 * program could add a "/usr/share/clipart" location when the sidebar is 503 * being used in an "Insert Clipart" dialog box. 504 * This function adds the specified location to a special place for immutable 505 * shortcuts. The shortcuts are application-specific; they are not shared 506 * across applications, and they are not persistent. If this function 507 * is called multiple times with different locations, then they are added 508 * to the sidebar's list in the same order as the function is called. 509 * Params: 510 * location = location to add as an application-specific shortcut 511 * Since 3.10 512 */ 513 public void addShortcut(File location) 514 { 515 // void gtk_places_sidebar_add_shortcut (GtkPlacesSidebar *sidebar, GFile *location); 516 gtk_places_sidebar_add_shortcut(gtkPlacesSidebar, (location is null) ? null : location.getFileStruct()); 517 } 518 519 /** 520 * Removes an application-specific shortcut that has been previously been 521 * inserted with gtk_places_sidebar_add_shortcut(). If the location is not a 522 * shortcut in the sidebar, then nothing is done. 523 * Params: 524 * location = location to remove 525 * Since 3.10 526 */ 527 public void removeShortcut(File location) 528 { 529 // void gtk_places_sidebar_remove_shortcut (GtkPlacesSidebar *sidebar, GFile *location); 530 gtk_places_sidebar_remove_shortcut(gtkPlacesSidebar, (location is null) ? null : location.getFileStruct()); 531 } 532 533 /** 534 * Gets the list of shortcuts. 535 * Returns: A GSList of GFile of the locations that have been added as application-specific shortcuts with gtk_places_sidebar_add_shortcut(). To free this list, you can use $(DDOC_COMMENT example) . [element-type GFile][transfer full] Since 3.10 536 */ 537 public ListSG listShortcuts() 538 { 539 // GSList * gtk_places_sidebar_list_shortcuts (GtkPlacesSidebar *sidebar); 540 auto p = gtk_places_sidebar_list_shortcuts(gtkPlacesSidebar); 541 542 if(p is null) 543 { 544 return null; 545 } 546 547 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 548 } 549 550 /** 551 * This function queries the bookmarks added by the user to the places sidebar, 552 * and returns one of them. This function is used by GtkFileChooser to implement 553 * the "Alt-1", "Alt-2", etc. shortcuts, which activate the cooresponding bookmark. 554 * Params: 555 * n = index of the bookmark to query 556 * Returns: The bookmark specified by the index n, or NULL if no such index exist. Note that the indices start at 0, even though the file chooser starts them with the keyboard shortcut "Alt-1". [transfer full] Since 3.10 557 */ 558 public File getNthBookmark(int n) 559 { 560 // GFile * gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar, gint n); 561 auto p = gtk_places_sidebar_get_nth_bookmark(gtkPlacesSidebar, n); 562 563 if(p is null) 564 { 565 return null; 566 } 567 568 return ObjectG.getDObject!(File)(cast(GFile*) p); 569 } 570 571 /** 572 * Returns the value previously set with gtk_places_sidebar_set_show_connect_to_server() 573 * Returns: TRUE if the sidebar will display a "Connect to Server" item. Since 3.10 574 */ 575 public int getShowConnectToServer() 576 { 577 // gboolean gtk_places_sidebar_get_show_connect_to_server (GtkPlacesSidebar *sidebar); 578 return gtk_places_sidebar_get_show_connect_to_server(gtkPlacesSidebar); 579 } 580 581 /** 582 * Sets whether the sidebar should show an item for connecting to a network server; this is off by default. 583 * An application may want to turn this on if it implements a way for the user to connect 584 * to network servers directly. 585 * Params: 586 * showConnectToServer = whether to show an item for the Connect to Server command 587 * Since 3.10 588 */ 589 public void setShowConnectToServer(int showConnectToServer) 590 { 591 // void gtk_places_sidebar_set_show_connect_to_server (GtkPlacesSidebar *sidebar, gboolean show_connect_to_server); 592 gtk_places_sidebar_set_show_connect_to_server(gtkPlacesSidebar, showConnectToServer); 593 } 594 }