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