gtk.places_sidebar

Module for [PlacesSidebar] class

Types 3

#GtkPlacesSidebar is a widget that displays a list of frequently-used places in the file system: the user’s home directory, the user’s bookmarks, and volumes and drives. This widget is used as a sidebar in #GtkFileChooser and may be used by file managers and similar programs.

The places sidebar displays drives and volumes, and will automatically mount or unmount them when the user selects them.

Applications can hook to various signals in the places sidebar to customize its behavior. For example, they can add extra commands to the context menu of the sidebar.

While bookmarks are completely in control of the user, the places sidebar also allows individual applications to provide extra shortcut folders that are unique to each application. For example, a Paint program may want to add a shortcut for a Clipart folder. You can do this with [gtk.places_sidebar.PlacesSidebar.addShortcut].

To make use of the places sidebar, an application at least needs to connect to the #GtkPlacesSidebar::open-location signal. This is emitted when the user selects in the sidebar a location to open. The application should also call [gtk.places_sidebar.PlacesSidebar.setLocation] when it changes the currently-viewed location.

CSS nodes

GtkPlacesSidebar uses a single CSS node with name placessidebar and style class .sidebar.

Among the children of the places sidebar, the following style classes can be used:

  • .sidebar-new-bookmark-row for the 'Add new bookmark' row
  • .sidebar-placeholder-row for a row that is a placeholder
  • .has-open-popup when a popup is open for a row
Methods
GType _gType() @property
PlacesSidebar self()Returns `this`, for use in `with` statements.
PlacesSidebarGidBuilder builder()Get builder for [gtk.places_sidebar.PlacesSidebar] Returns: New builder object
bool localOnly() @property
void localOnly(bool propval) @property
void location(gio.file.File propval) @property
void openFlags(gtk.types.PlacesOpenFlags propval) @property
bool populateAll() @propertyGet `populateAll` property. Returns: If :populate-all is true, the #GtkPlacesSidebar::populate-popup signal is also emitted for popovers.
void populateAll(bool propval) @propertySet `populateAll` property. Params: propval = If :populate-all is true, the #GtkPlacesSidebar::populate-popup signal is also emitted for popovers.
bool showConnectToServer() @property
void showConnectToServer(bool propval) @property
bool showDesktop() @property
void showDesktop(bool propval) @property
bool showEnterLocation() @property
void showEnterLocation(bool propval) @property
bool showOtherLocations() @property
void showOtherLocations(bool propval) @property
bool showRecent() @property
void showRecent(bool propval) @property
bool showStarredLocation() @property
void showStarredLocation(bool propval) @property
bool showTrash() @property
void showTrash(bool propval) @property
void addShortcut(gio.file.File location)Applications may want to present some folders in the places sidebar if they could be immediately useful to users. For example, a drawing program could add a “/usr/share/clipart” location when ...
bool getLocalOnly()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setLocalOnly]. Returns: true if the sidebar will only show local files.
gio.file.File getLocation()Gets the currently selected location in the sidebar. This can be null when nothing is selected, for example, when [gtk.places_sidebar.PlacesSidebar.setLocation] has been called with a location that...
gio.file.File getNthBookmark(int n)This function queries the bookmarks added by the user to the places sidebar, and returns one of them. This function is used by #GtkFileChooser to implement the “Alt-1”, “Alt-2”, etc. short...
gtk.types.PlacesOpenFlags getOpenFlags()Gets the open flags. Returns: the #GtkPlacesOpenFlags of sidebar
bool getShowConnectToServer()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setShowConnectToServer] Returns: true if the sidebar will display a “Connect to Server” item.
bool getShowDesktop()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setShowDesktop] Returns: true if the sidebar will display a builtin shortcut to the desktop folder.
bool getShowEnterLocation()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setShowEnterLocation] Returns: true if the sidebar will display an “Enter Location” item.
bool getShowOtherLocations()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setShowOtherLocations] Returns: true if the sidebar will display an “Other Locations” item.
bool getShowRecent()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setShowRecent] Returns: true if the sidebar will display a builtin shortcut for recent files
bool getShowStarredLocation()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setShowStarredLocation] Returns: true if the sidebar will display a Starred item.
bool getShowTrash()Returns the value previously set with [gtk.places_sidebar.PlacesSidebar.setShowTrash] Returns: true if the sidebar will display a “Trash” item.
gio.file.File[] listShortcuts()Gets the list of shortcuts. Returns: A #GSList of #GFile of the locations that have been added as application-specific shortcuts with [gtk.placessidebar.PlacesSidebar.addShortcut]. To free this lis...
void removeShortcut(gio.file.File location)Removes an application-specific shortcut that has been previously been inserted with [gtk.places_sidebar.PlacesSidebar.addShortcut]. If the location is not a shortcut in the sidebar, then nothing ...
void setDropTargetsVisible(bool visible, gdk.drag_context.DragContext context)Make the GtkPlacesSidebar show drop targets, so it can show the available drop targets and a "new bookmark" row. This improves the Drag-and-Drop experience of the user and allows applications to sh...
void setLocalOnly(bool localOnly)Sets whether the sidebar should only show local files.
void setLocation(gio.file.File location = null)Sets the location that is being shown in the widgets surrounding the sidebar, for example, in a folder view in a file manager. In turn, the sidebar will highlight that location if it is being show...
void setOpenFlags(gtk.types.PlacesOpenFlags flags)Sets the way in which the calling application can open new locations from the places sidebar. For example, some applications only open locations “directly” into their main view, while others m...
void setShowConnectToServer(bool showConnectToServer)Sets whether the sidebar should show an item for connecting to a network server; this is off by default. An application may want to turn this on if it implements a way for the user to connect to ne...
void setShowDesktop(bool showDesktop)Sets whether the sidebar should show an item for the Desktop folder. The default value for this option is determined by the desktop environment and the user’s configuration, but this function can...
void setShowEnterLocation(bool showEnterLocation)Sets whether the sidebar should show an item for entering a location; this is off by default. An application may want to turn this on if manually entering URLs is an expected user action.
void setShowOtherLocations(bool showOtherLocations)Sets whether the sidebar should show an item for the application to show an Other Locations view; this is off by default. When set to true, persistent devices such as hard drives are hidden, otherw...
void setShowRecent(bool showRecent)Sets whether the sidebar should show an item for recent files. The default value for this option is determined by the desktop environment, but this function can be used to override it on a per-appl...
void setShowStarredLocation(bool showStarredLocation)If you enable this, you should connect to the #GtkPlacesSidebar::show-starred-location signal.
void setShowTrash(bool showTrash)Sets whether the sidebar should show an item for the Trash location.
gulong connectDragActionAsk(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == int) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == int))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 3)Connect to `DragActionAsk` signal.
gulong connectDragActionRequested(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == int) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gdk.drag_context.DragContext))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gio.file.File))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == gio.file.File[]))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 5)Connect to `DragActionRequested` signal.
gulong connectDragPerformDrop(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gio.file.File))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gio.file.File[]))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == int))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 5)Connect to `DragPerformDrop` signal.
gulong connectMount(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gio.mount_operation.MountOperation))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 3)Connect to `Mount` signal.
gulong connectOpenLocation(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gio.file.File))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gtk.types.PlacesOpenFlags))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 4)Connect to `OpenLocation` signal.
gulong connectPopulatePopup(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.widget.Widget))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gio.file.File))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gio.volume.Volume))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 5)Connect to `PopulatePopup` signal.
gulong connectShowConnectToServer(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 2)Connect to `ShowConnectToServer` signal.
gulong connectShowEnterLocation(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 2)Connect to `ShowEnterLocation` signal.
gulong connectShowErrorMessage(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == string))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 4)Connect to `ShowErrorMessage` signal.
gulong connectShowOtherLocations(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 2)Connect to `ShowOtherLocations` signal.
gulong connectShowOtherLocationsWithFlags(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.PlacesOpenFlags))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 3)Connect to `ShowOtherLocationsWithFlags` signal.
gulong connectShowStarredLocation(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.PlacesOpenFlags))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 3)Connect to `ShowStarredLocation` signal.
gulong connectUnmount(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gio.mount_operation.MountOperation))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.places_sidebar.PlacesSidebar))) && Parameters!T.length < 3)Connect to `Unmount` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new #GtkPlacesSidebar widget.
Methods
T localOnly(bool propval)
T populateAll(bool propval)Set `populateAll` property. Params: propval = If :populate-all is true, the #GtkPlacesSidebar::populate-popup signal is also emitted for popovers. Returns: Builder instance for fluent chaining
T showConnectToServer(bool propval)
T showDesktop(bool propval)
T showEnterLocation(bool propval)
T showOtherLocations(bool propval)
T showRecent(bool propval)
T showStarredLocation(bool propval)
T showTrash(bool propval)

Fluent builder for [gtk.places_sidebar.PlacesSidebar]