Gtk.PlacesSidebar¶
Example¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.ScrolledWindow (33), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Whether the sidebar only includes local files |
||
r/w |
The location to highlight in the sidebar |
||
r/w |
Modes in which the calling application can open locations selected in the sidebar |
||
r/w |
Whether to emit |
||
d/r/w |
Whether the sidebar includes a builtin shortcut to a ‘Connect to server’ dialog |
||
r/w |
Whether the sidebar includes a builtin shortcut to the Desktop folder |
||
r/w |
Whether the sidebar includes a builtin shortcut to manually enter a location |
||
r/w |
Whether the sidebar includes an item to show external locations |
||
r/w |
Whether the sidebar includes a builtin shortcut for recent files |
||
r/w |
Whether the sidebar includes an item to show starred files |
||
r/w |
Whether the sidebar includes a builtin shortcut to the Trash location |
Style Properties¶
- Inherited:
Signals¶
Name |
Short Description |
---|---|
The places sidebar emits this signal when it needs to ask the application to pop up a menu to ask the user for which drag action to perform. |
|
When the user starts a drag-and-drop operation and the sidebar needs to ask the application for which drag action to perform, then the sidebar will emit this signal. |
|
The places sidebar emits this signal when the user completes a drag-and-drop operation and one of the sidebar’s items is the destination. |
|
The places sidebar emits this signal when it starts a new operation because the user clicked on some location that needs mounting. |
|
The places sidebar emits this signal when the user selects a location in it. |
|
The places sidebar emits this signal when the user invokes a contextual popup on one of its items. |
|
The places sidebar emits this signal when it needs the calling application to present an way to connect directly to a network server. |
|
The places sidebar emits this signal when it needs the calling application to present an way to directly enter a location. |
|
The places sidebar emits this signal when it needs the calling application to present an error message. |
|
The places sidebar emits this signal when it needs the calling application to present a way to show other locations e.g. |
|
The places sidebar emits this signal when it needs the calling application to present a way to show other locations e.g. |
|
The places sidebar emits this signal when it needs the calling application to present a way to show the starred files. |
|
The places sidebar emits this signal when it starts a new operation because the user for example ejected some drive or unmounted a mount. |
Fields¶
Class Details¶
- class Gtk.PlacesSidebar(*args, **kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Gtk.PlacesSidebar
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 inGtk.FileChooser
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.PlacesSidebar.add_shortcut
().To make use of the places sidebar, an application at least needs to connect to the
Gtk.PlacesSidebar
::open-location
signal. This is emitted when the user selects in the sidebar a location to open. The application should also callGtk.PlacesSidebar.set_location
() when it changes the currently-viewed location.- CSS nodes
Gtk.PlacesSidebar
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
- classmethod new()[source]¶
- Returns:
a newly created
Gtk.PlacesSidebar
- Return type:
Creates a new
Gtk.PlacesSidebar
widget.The application should connect to at least the
Gtk.PlacesSidebar
::open-location
signal to be notified when the user makes a selection in the sidebar.New in version 3.10.
- add_shortcut(location)[source]¶
- Parameters:
location (
Gio.File
) – location to add as an application-specific shortcut
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 the sidebar is being used in an “Insert Clipart” dialog box.
This function adds the specified location to a special place for immutable shortcuts. The shortcuts are application-specific; they are not shared across applications, and they are not persistent. If this function is called multiple times with different locations, then they are added to the sidebar’s list in the same order as the function is called.
New in version 3.10.
- get_local_only()[source]¶
-
Returns the value previously set with
Gtk.PlacesSidebar.set_local_only
().New in version 3.12.
- get_location()[source]¶
- Returns:
a
Gio.File
with the selected location, orNone
if nothing is visually selected.- Return type:
Gets the currently selected location in the self. This can be
None
when nothing is selected, for example, whenGtk.PlacesSidebar.set_location
() has been called with a location that is not among the sidebar’s list of places to show.You can use this function to get the selection in the self. Also, if you connect to the
Gtk.PlacesSidebar
::populate-popup
signal, you can use this function to get the location that is being referred to during the callbacks for your menu items.New in version 3.10.
- get_nth_bookmark(n)[source]¶
- Parameters:
n (
int
) – index of the bookmark to query- Returns:
The bookmark specified by the index n, or
None
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”.- Return type:
This function queries the bookmarks added by the user to the places sidebar, and returns one of them. This function is used by
Gtk.FileChooser
to implement the “Alt-1”, “Alt-2”, etc. shortcuts, which activate the cooresponding bookmark.New in version 3.10.
- get_open_flags()[source]¶
- Returns:
the
Gtk.PlacesOpenFlags
of self- Return type:
Gets the open flags.
New in version 3.10.
- get_show_connect_to_server()[source]¶
-
Returns the value previously set with
Gtk.PlacesSidebar.set_show_connect_to_server
()Deprecated since version 3.18: It is recommended to group this functionality with the drives and network location under the new ‘Other Location’ item
- get_show_desktop()[source]¶
- Returns:
True
if the sidebar will display a builtin shortcut to the desktop folder.- Return type:
Returns the value previously set with
Gtk.PlacesSidebar.set_show_desktop
()New in version 3.10.
- get_show_enter_location()[source]¶
-
Returns the value previously set with
Gtk.PlacesSidebar.set_show_enter_location
()New in version 3.14.
- get_show_other_locations()[source]¶
-
Returns the value previously set with
Gtk.PlacesSidebar.set_show_other_locations
()New in version 3.18.
- get_show_recent()[source]¶
-
Returns the value previously set with
Gtk.PlacesSidebar.set_show_recent
()New in version 3.18.
- get_show_starred_location()[source]¶
-
Returns the value previously set with
Gtk.PlacesSidebar.set_show_starred_location
()New in version 3.22.26.
- get_show_trash()[source]¶
-
Returns the value previously set with
Gtk.PlacesSidebar.set_show_trash
()New in version 3.18.
- list_shortcuts()[source]¶
- Returns:
A
GLib.SList
ofGio.File
of the locations that have been added as application-specific shortcuts withGtk.PlacesSidebar.add_shortcut
(). To free this list, you can useg_slist_free_full (list, (GDestroyNotify) g_object_unref);
- Return type:
[
Gio.File
]
Gets the list of shortcuts.
New in version 3.10.
- remove_shortcut(location)[source]¶
- Parameters:
location (
Gio.File
) – location to remove
Removes an application-specific shortcut that has been previously been inserted with
Gtk.PlacesSidebar.add_shortcut
(). If the location is not a shortcut in the sidebar, then nothing is done.New in version 3.10.
- set_drop_targets_visible(visible, context)[source]¶
- Parameters:
visible (
bool
) – whether to show the valid targets or not.context (
Gdk.DragContext
) – drag context used to ask the source about the action that wants to perform, so hints are more accurate.
Make the
Gtk.PlacesSidebar
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 show all available drop targets at once.This needs to be called when the application is aware of an ongoing drag that might target the sidebar. The drop-targets-visible state will be unset automatically if the drag finishes in the
Gtk.PlacesSidebar
. You only need to unset the state when the drag ends on some other widget on your application.New in version 3.18.
- set_local_only(local_only)[source]¶
- Parameters:
local_only (
bool
) – whether to show only local files
Sets whether the self should only show local files.
New in version 3.12.
- set_location(location)[source]¶
-
Sets the location that is being shown in the widgets surrounding the self, for example, in a folder view in a file manager. In turn, the self will highlight that location if it is being shown in the list of places, or it will unhighlight everything if the location is not among the places in the list.
New in version 3.10.
- set_open_flags(flags)[source]¶
- Parameters:
flags (
Gtk.PlacesOpenFlags
) – Bitmask of modes in which the calling application can open locations
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 may support opening locations in a new notebook tab or a new window.
This function is used to tell the places self about the ways in which the application can open new locations, so that the sidebar can display (or not) the “Open in new tab” and “Open in new window” menu items as appropriate.
When the
Gtk.PlacesSidebar
::open-location
signal is emitted, its flags argument will be set to one of the flags that was passed inGtk.PlacesSidebar.set_open_flags
().Passing 0 for flags will cause
Gtk.PlacesOpenFlags.NORMAL
to always be sent to callbacks for the “open-location” signal.New in version 3.10.
- set_show_connect_to_server(show_connect_to_server)[source]¶
- Parameters:
show_connect_to_server (
bool
) – whether to show an item for the Connect to Server command
Sets whether the self 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 network servers directly.
If you enable this, you should connect to the
Gtk.PlacesSidebar
::show-connect-to-server
signal.New in version 3.10.
Deprecated since version 3.18: It is recommended to group this functionality with the drives and network location under the new ‘Other Location’ item
- set_show_desktop(show_desktop)[source]¶
- Parameters:
show_desktop (
bool
) – whether to show an item for the Desktop folder
Sets whether the self 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 be used to override it on a per-application basis.
New in version 3.10.
- set_show_enter_location(show_enter_location)[source]¶
- Parameters:
show_enter_location (
bool
) – whether to show an item to enter a location
Sets whether the self 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.
If you enable this, you should connect to the
Gtk.PlacesSidebar
::show-enter-location
signal.New in version 3.14.
- set_show_other_locations(show_other_locations)[source]¶
- Parameters:
show_other_locations (
bool
) – whether to show an item for the Other Locations view
Sets whether the self 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, otherwise they are shown in the sidebar. An application may want to turn this on if it implements a way for the user to see and interact with drives and network servers directly.If you enable this, you should connect to the
Gtk.PlacesSidebar
::show-other-locations
signal.New in version 3.18.
- set_show_recent(show_recent)[source]¶
- Parameters:
show_recent (
bool
) – whether to show an item for recent files
Sets whether the self 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-application basis.
New in version 3.18.
- set_show_starred_location(show_starred_location)[source]¶
- Parameters:
show_starred_location (
bool
) – whether to show an item for Starred files
If you enable this, you should connect to the
Gtk.PlacesSidebar
::show-starred-location
signal.New in version 3.22.26.
Signal Details¶
- Gtk.PlacesSidebar.signals.drag_action_ask(places_sidebar, actions)¶
- Signal Name:
drag-action-ask
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalactions (
int
) – Possible drag actions that need to be asked for.
- Returns:
the final drag action that the sidebar should pass to the drag side of the drag-and-drop operation.
- Return type:
The places sidebar emits this signal when it needs to ask the application to pop up a menu to ask the user for which drag action to perform.
New in version 3.10.
- Gtk.PlacesSidebar.signals.drag_action_requested(places_sidebar, context, dest_file, source_file_list)¶
- Signal Name:
drag-action-requested
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalcontext (
Gdk.DragContext
) –Gdk.DragContext
with information about the drag operationdest_file (
Gio.File
) –Gio.File
with the tentative location that is being hovered for a dropsource_file_list ([
Gio.File
]) – List ofGio.File
that are being dragged
- Returns:
The drag action to use, for example,
Gdk.DragAction.COPY
orGdk.DragAction.MOVE
, or 0 if no action is allowed here (i.e. drops are not allowed in the specified dest_file).- Return type:
When the user starts a drag-and-drop operation and the sidebar needs to ask the application for which drag action to perform, then the sidebar will emit this signal.
The application can evaluate the context for customary actions, or it can check the type of the files indicated by source_file_list against the possible actions for the destination dest_file.
The drag action to use must be the return value of the signal handler.
New in version 3.10.
- Gtk.PlacesSidebar.signals.drag_perform_drop(places_sidebar, dest_file, source_file_list, action)¶
- Signal Name:
drag-perform-drop
- Flags:
- Parameters:
The places sidebar emits this signal when the user completes a drag-and-drop operation and one of the sidebar’s items is the destination. This item is in the dest_file, and the source_file_list has the list of files that are dropped into it and which should be copied/moved/etc. based on the specified action.
New in version 3.10.
- Gtk.PlacesSidebar.signals.mount(places_sidebar, mount_operation)¶
- Signal Name:
mount
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalmount_operation (
Gio.MountOperation
) – theGio.MountOperation
that is going to start.
The places sidebar emits this signal when it starts a new operation because the user clicked on some location that needs mounting. In this way the application using the
Gtk.PlacesSidebar
can track the progress of the operation and, for example, show a notification.New in version 3.20.
- Gtk.PlacesSidebar.signals.open_location(places_sidebar, location, open_flags)¶
- Signal Name:
open-location
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signallocation (
Gio.File
) –Gio.File
to which the caller should switch.open_flags (
Gtk.PlacesOpenFlags
) – a single value fromGtk.PlacesOpenFlags
specifying how the location should be opened.
The places sidebar emits this signal when the user selects a location in it. The calling application should display the contents of that location; for example, a file manager should show a list of files in the specified location.
New in version 3.10.
- Gtk.PlacesSidebar.signals.populate_popup(places_sidebar, container, selected_item, selected_volume)¶
- Signal Name:
populate-popup
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalcontainer (
Gtk.Widget
) – aGtk.Menu
or anotherGtk.Container
selected_item (
Gio.File
orNone
) –Gio.File
with the item to which the popup should refer, orNone
in the case of a selected_volume.selected_volume (
Gio.Volume
orNone
) –Gio.Volume
if the selected item is a volume, orNone
if it is a file.
The places sidebar emits this signal when the user invokes a contextual popup on one of its items. In the signal handler, the application may add extra items to the menu as appropriate. For example, a file manager may want to add a “Properties” command to the menu.
It is not necessary to store the selected_item for each menu item; during their callbacks, the application can use
Gtk.PlacesSidebar.get_location
() to get the file to which the item refers.The selected_item argument may be
None
in case the selection refers to a volume. In this case, selected_volume will be non-None
. In this case, the calling application will have toGObject.Object.ref
() the selected_volume and keep it around to use it in the callback.The container and all its contents are destroyed after the user dismisses the popup. The popup is re-created (and thus, this signal is emitted) every time the user activates the contextual menu.
Before 3.18, the container always was a
Gtk.Menu
, and you were expected to add your items asGtk.MenuItems
. Since 3.18, the popup may be implemented as aGtk.Popover
, in which case container will be something else, e.g. aGtk.Box
, to which you may addGtk.ModelButtons
or other widgets, such as #GtkEntries,Gtk.SpinButtons
, etc. If your application can deal with this situation, you can setGtk.PlacesSidebar
::populate-all
toTrue
to request that this signal is emitted for populating popovers as well.New in version 3.10.
- Gtk.PlacesSidebar.signals.show_connect_to_server(places_sidebar)¶
- Signal Name:
show-connect-to-server
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signal
The places sidebar emits this signal when it needs the calling application to present an way to connect directly to a network server. For example, the application may bring up a dialog box asking for a URL like “sftp://ftp.example.com”. It is up to the application to create the corresponding mount by using, for example,
Gio.File.mount_enclosing_volume
().Deprecated since version 3.18: use the
Gtk.PlacesSidebar
::show-other-locations
signal to connect to network servers.
- Gtk.PlacesSidebar.signals.show_enter_location(places_sidebar)¶
- Signal Name:
show-enter-location
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signal
The places sidebar emits this signal when it needs the calling application to present an way to directly enter a location. For example, the application may bring up a dialog box asking for a URL like “http://http.example.com”.
New in version 3.14.
- Gtk.PlacesSidebar.signals.show_error_message(places_sidebar, primary, secondary)¶
- Signal Name:
show-error-message
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalprimary (
str
) – primary message with a summary of the error to show.secondary (
str
) – secondary message with details of the error to show.
The places sidebar emits this signal when it needs the calling application to present an error message. Most of these messages refer to mounting or unmounting media, for example, when a drive cannot be started for some reason.
New in version 3.10.
- Gtk.PlacesSidebar.signals.show_other_locations(places_sidebar)¶
- Signal Name:
show-other-locations
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signal
The places sidebar emits this signal when it needs the calling application to present a way to show other locations e.g. drives and network access points. For example, the application may bring up a page showing persistent volumes and discovered network addresses.
New in version 3.18.
Deprecated since version 3.20: use the
Gtk.PlacesSidebar
::show-other-locations-with-flags
which includes the open flags in order to allow the user to specify to open in a new tab or window, in a similar way thanGtk.PlacesSidebar
::open-location
- Gtk.PlacesSidebar.signals.show_other_locations_with_flags(places_sidebar, open_flags)¶
- Signal Name:
show-other-locations-with-flags
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalopen_flags (
Gtk.PlacesOpenFlags
) – a single value fromGtk.PlacesOpenFlags
specifying how it should be opened.
The places sidebar emits this signal when it needs the calling application to present a way to show other locations e.g. drives and network access points. For example, the application may bring up a page showing persistent volumes and discovered network addresses.
New in version 3.20.
- Gtk.PlacesSidebar.signals.show_starred_location(places_sidebar, open_flags)¶
- Signal Name:
show-starred-location
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalopen_flags (
Gtk.PlacesOpenFlags
) – a single value fromGtk.PlacesOpenFlags
specifying how the starred file should be opened.
The places sidebar emits this signal when it needs the calling application to present a way to show the starred files. In GNOME, starred files are implemented by setting the nao:predefined-tag-favorite tag in the tracker database.
New in version 3.22.26.
- Gtk.PlacesSidebar.signals.unmount(places_sidebar, mount_operation)¶
- Signal Name:
unmount
- Flags:
- Parameters:
places_sidebar (
Gtk.PlacesSidebar
) – The object which received the signalmount_operation (
Gio.MountOperation
) – theGio.MountOperation
that is going to start.
The places sidebar emits this signal when it starts a new operation because the user for example ejected some drive or unmounted a mount. In this way the application using the
Gtk.PlacesSidebar
can track the progress of the operation and, for example, show a notification.New in version 3.20.
Property Details¶
- Gtk.PlacesSidebar.props.local_only¶
-
Whether the sidebar only includes local files
- Gtk.PlacesSidebar.props.location¶
-
The location to highlight in the sidebar
- Gtk.PlacesSidebar.props.open_flags¶
- Name:
open-flags
- Type:
- Default Value:
- Flags:
Modes in which the calling application can open locations selected in the sidebar
- Gtk.PlacesSidebar.props.populate_all¶
-
If
:populate-all
isTrue
, theGtk.PlacesSidebar
::populate-popup
signal is also emitted for popovers.New in version 3.18.
- Gtk.PlacesSidebar.props.show_connect_to_server¶
- Name:
show-connect-to-server
- Type:
- Default Value:
- Flags:
Whether the sidebar includes a builtin shortcut to a ‘Connect to server’ dialog
Deprecated since version ???.
- Gtk.PlacesSidebar.props.show_desktop¶
-
Whether the sidebar includes a builtin shortcut to the Desktop folder
- Gtk.PlacesSidebar.props.show_enter_location¶
-
Whether the sidebar includes a builtin shortcut to manually enter a location
- Gtk.PlacesSidebar.props.show_other_locations¶
-
Whether the sidebar includes an item to show external locations
- Gtk.PlacesSidebar.props.show_recent¶
-
Whether the sidebar includes a builtin shortcut for recent files
- Gtk.PlacesSidebar.props.show_starred_location¶
-
Whether the sidebar includes an item to show starred files