Struct gtk::PlacesSidebar [−][src]
pub struct PlacesSidebar(_);
Expand description
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 in 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 add_shortcut()
.
To make use of the places sidebar, an application at least needs to connect
to the signal::PlacesSidebar::open-location
signal. This is emitted when the
user selects in the sidebar a location to open. The application should also
call set_location()
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
Implements
ScrolledWindowExt
, BinExt
, ContainerExt
, WidgetExt
, glib::ObjectExt
, BuildableExt
, WidgetExtManual
, BuildableExtManual
Implementations
Creates a new PlacesSidebar
widget.
The application should connect to at least the
signal::PlacesSidebar::open-location
signal to be notified
when the user makes a selection in the sidebar.
Returns
a newly created PlacesSidebar
Creates a new builder-pattern struct instance to construct PlacesSidebar
objects.
This method returns an instance of PlacesSidebarBuilder
which can be used to create PlacesSidebar
objects.
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.
location
location to add as an application-specific shortcut
Returns the value previously set with set_local_only()
.
Returns
true
if the sidebar will only show local files.
Gets the currently selected location in the self
. This can be None
when
nothing is selected, for example, when 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 signal::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.
Returns
a gio::File
with the selected location, or
None
if nothing is visually selected.
This function queries the bookmarks added by the user to the places sidebar,
and returns one of them. This function is used by FileChooser
to implement
the “Alt-1”, “Alt-2”, etc. shortcuts, which activate the cooresponding bookmark.
n
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”.
Returns the value previously set with set_show_desktop()
Returns
true
if the sidebar will display a builtin shortcut to the desktop folder.
Returns the value previously set with set_show_enter_location()
Returns
true
if the sidebar will display an “Enter Location” item.
Returns the value previously set with set_show_other_locations()
Returns
true
if the sidebar will display an “Other Locations” item.
Returns the value previously set with set_show_recent()
Returns
true
if the sidebar will display a builtin shortcut for recent files
This is supported on crate feature v3_22_26
only.
v3_22_26
only.Returns the value previously set with set_show_starred_location()
Returns
true
if the sidebar will display a Starred item.
Returns the value previously set with set_show_trash()
Returns
true
if the sidebar will display a “Trash” item.
Gets the list of shortcuts.
Returns
A GSList
of gio::File
of the locations that have been added as
application-specific shortcuts with add_shortcut()
.
To free this list, you can use
⚠️ The following code is in C ⚠️
g_slist_free_full (list, (GDestroyNotify) g_object_unref);
Removes an application-specific shortcut that has been previously been
inserted with add_shortcut()
. If the location
is not a
shortcut in the sidebar, then nothing is done.
location
location to remove
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 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 GtkPlacesSidebar. You only need to unset the state when the drag ends on some other widget on your application.
visible
whether to show the valid targets or not.
context
drag context used to ask the source about the action that wants to perform, so hints are more accurate.
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.
location
location to select, or None
for no current path
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 signal::PlacesSidebar::open-location
signal is emitted, its flags
argument will be set to one of the flags
that was passed in
set_open_flags()
.
Passing 0 for flags
will cause PlacesOpenFlags::NORMAL
to always be sent
to callbacks for the “open-location” signal.
flags
Bitmask of modes in which the calling application can open locations
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.
show_desktop
whether to show an item for the Desktop folder
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
signal::PlacesSidebar::show-enter-location
signal.
show_enter_location
whether to show an item to enter a location
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
signal::PlacesSidebar::show-other-locations
signal.
show_other_locations
whether to show an item for the Other Locations view
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.
show_recent
whether to show an item for recent files
This is supported on crate feature v3_22_26
only.
v3_22_26
only.If you enable this, you should connect to the
signal::PlacesSidebar::show-starred-location
signal.
show_starred_location
whether to show an item for Starred files
Sets whether the self
should show an item for the Trash location.
show_trash
whether to show an item for the Trash location
If :populate-all is true
, the signal::PlacesSidebar::populate-popup
signal
is also emitted for popovers.
If :populate-all is true
, the signal::PlacesSidebar::populate-popup
signal
is also emitted for popovers.
pub fn connect_drag_action_ask<F: Fn(&Self, i32) -> i32 + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_drag_action_ask<F: Fn(&Self, i32) -> i32 + 'static>(
&self,
f: F
) -> SignalHandlerId
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.
actions
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.
This is supported on crate feature v3_20
only.
v3_20
only.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 PlacesSidebar
can track the
progress of the operation and, for example, show a notification.
mount_operation
the gio::MountOperation
that is going to start.
pub fn connect_open_location<F: Fn(&Self, &File, PlacesOpenFlags) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_open_location<F: Fn(&Self, &File, PlacesOpenFlags) + 'static>(
&self,
f: F
) -> SignalHandlerId
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.
location
gio::File
to which the caller should switch.
open_flags
a single value from PlacesOpenFlags
specifying how the location
should be opened.
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”.
pub fn connect_show_error_message<F: Fn(&Self, &str, &str) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_show_error_message<F: Fn(&Self, &str, &str) + 'static>(
&self,
f: F
) -> SignalHandlerId
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.
primary
primary message with a summary of the error to show.
secondary
secondary message with details of the error to show.
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.
Deprecated since 3.20
use the signal::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 than signal::PlacesSidebar::open-location
pub fn connect_show_other_locations_with_flags<F: Fn(&Self, PlacesOpenFlags) + 'static>(
&self,
f: F
) -> SignalHandlerId
This is supported on crate feature v3_20
only.
pub fn connect_show_other_locations_with_flags<F: Fn(&Self, PlacesOpenFlags) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_20
only.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.
open_flags
a single value from PlacesOpenFlags
specifying how it should be opened.
pub fn connect_show_starred_location<F: Fn(&Self, PlacesOpenFlags) + 'static>(
&self,
f: F
) -> SignalHandlerId
This is supported on crate feature v3_22_26
only.
pub fn connect_show_starred_location<F: Fn(&Self, PlacesOpenFlags) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_22_26
only.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.
open_flags
a single value from PlacesOpenFlags
specifying how the
starred file should be opened.
pub fn connect_unmount<F: Fn(&Self, &MountOperation) + 'static>(
&self,
f: F
) -> SignalHandlerId
This is supported on crate feature v3_20
only.
pub fn connect_unmount<F: Fn(&Self, &MountOperation) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_20
only.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 PlacesSidebar
can track the
progress of the operation and, for example, show a notification.
mount_operation
the gio::MountOperation
that is going to start.
pub fn connect_show_connect_to_server_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_show_enter_location_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_show_other_locations_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_show_starred_location_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
v3_22_26
only.Trait Implementations
type Parent = ScrolledWindow
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for PlacesSidebar
impl !Send for PlacesSidebar
impl !Sync for PlacesSidebar
impl Unpin for PlacesSidebar
impl UnwindSafe for PlacesSidebar
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Emit signal with details by signal id.
Emit signal by it’s name.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,