342 lines
17 KiB
Swift
342 lines
17 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
|
|
// PorticoGen: generateStruct | source: Gtk.FileChooserWidget
|
|
/// `GtkFileChooserWidget` is a widget for choosing files.
|
|
///
|
|
/// It exposes the [iface`Gtk`.FileChooser] interface, and you should
|
|
/// use the methods of this interface to interact with the
|
|
/// widget.
|
|
///
|
|
/// # Shortcuts and Gestures
|
|
///
|
|
/// `GtkFileChooserWidget` supports the following keyboard shortcuts:
|
|
///
|
|
/// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
|
|
///
|
|
/// The following signals have default keybindings:
|
|
///
|
|
/// - [signal`Gtk`.FileChooserWidget::desktop-folder]
|
|
/// - [signal`Gtk`.FileChooserWidget::down-folder]
|
|
/// - [signal`Gtk`.FileChooserWidget::home-folder]
|
|
/// - [signal`Gtk`.FileChooserWidget::location-popup]
|
|
/// - [signal`Gtk`.FileChooserWidget::location-popup-on-paste]
|
|
/// - [signal`Gtk`.FileChooserWidget::location-toggle-popup]
|
|
/// - [signal`Gtk`.FileChooserWidget::places-shortcut]
|
|
/// - [signal`Gtk`.FileChooserWidget::quick-bookmark]
|
|
/// - [signal`Gtk`.FileChooserWidget::recent-shortcut]
|
|
/// - [signal`Gtk`.FileChooserWidget::search-shortcut]
|
|
/// - [signal`Gtk`.FileChooserWidget::show-hidden]
|
|
/// - [signal`Gtk`.FileChooserWidget::up-folder]
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// `GtkFileChooserWidget` has a single CSS node with name filechooser.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.FileChooserWidget`.
|
|
@MainActor public struct FileChooserWidget: View {
|
|
private let make: (MountContext) -> Gtk.FileChooserWidget
|
|
private var configure: [(Gtk.FileChooserWidget, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.FileChooserWidget.init(action:)
|
|
/// Creates a new `GtkFileChooserWidget`.
|
|
///
|
|
/// This is a file chooser widget that can be embedded in custom
|
|
/// windows, and it is the same widget that is used by
|
|
/// `GtkFileChooserDialog`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
|
|
///
|
|
/// - Parameter action: The `action` value forwarded to `Gtk.FileChooserWidget`.
|
|
/// - Parameter onDesktopFolder: Invoked when the widget emits the `desktop-folder` signal.
|
|
/// - Parameter onDownFolder: Invoked when the widget emits the `down-folder` signal.
|
|
/// - Parameter onHomeFolder: Invoked when the widget emits the `home-folder` signal.
|
|
/// - Parameter onLocationPopup: Invoked when the widget emits the `location-popup` signal. The closure receives the signal's arguments in order.
|
|
/// - Parameter onLocationPopupOnPaste: Invoked when the widget emits the `location-popup-on-paste` signal.
|
|
/// - Parameter onLocationTogglePopup: Invoked when the widget emits the `location-toggle-popup` signal.
|
|
/// - Parameter onPlacesShortcut: Invoked when the widget emits the `places-shortcut` signal.
|
|
/// - Parameter onQuickBookmark: Invoked when the widget emits the `quick-bookmark` signal. The closure receives the signal's arguments in order.
|
|
/// - Parameter onRecentShortcut: Invoked when the widget emits the `recent-shortcut` signal.
|
|
/// - Parameter onSearchShortcut: Invoked when the widget emits the `search-shortcut` signal.
|
|
/// - Parameter onShowHidden: Invoked when the widget emits the `show-hidden` signal.
|
|
/// - Parameter onUpFolder: Invoked when the widget emits the `up-folder` signal.
|
|
public init(action: Gtk.FileChooserAction, onDesktopFolder: (() -> Void)? = nil, onDownFolder: (() -> Void)? = nil, onHomeFolder: (() -> Void)? = nil, onLocationPopup: ((String) -> Void)? = nil, onLocationPopupOnPaste: (() -> Void)? = nil, onLocationTogglePopup: (() -> Void)? = nil, onPlacesShortcut: (() -> Void)? = nil, onQuickBookmark: ((Int32) -> Void)? = nil, onRecentShortcut: (() -> Void)? = nil, onSearchShortcut: (() -> Void)? = nil, onShowHidden: (() -> Void)? = nil, onUpFolder: (() -> Void)? = nil) {
|
|
make = { _ in Gtk.FileChooserWidget(action: action) }
|
|
configure.append { w, ctx in
|
|
if let onDesktopFolder { ctx.registry.add(w.connectDesktopFolder { _ in onDesktopFolder() }) }
|
|
if let onDownFolder { ctx.registry.add(w.connectDownFolder { _ in onDownFolder() }) }
|
|
if let onHomeFolder { ctx.registry.add(w.connectHomeFolder { _ in onHomeFolder() }) }
|
|
if let onLocationPopup { ctx.registry.add(w.connectLocationPopup { _, a0 in onLocationPopup(a0) }) }
|
|
if let onLocationPopupOnPaste { ctx.registry.add(w.connectLocationPopupOnPaste { _ in onLocationPopupOnPaste() }) }
|
|
if let onLocationTogglePopup { ctx.registry.add(w.connectLocationTogglePopup { _ in onLocationTogglePopup() }) }
|
|
if let onPlacesShortcut { ctx.registry.add(w.connectPlacesShortcut { _ in onPlacesShortcut() }) }
|
|
if let onQuickBookmark { ctx.registry.add(w.connectQuickBookmark { _, a0 in onQuickBookmark(a0) }) }
|
|
if let onRecentShortcut { ctx.registry.add(w.connectRecentShortcut { _ in onRecentShortcut() }) }
|
|
if let onSearchShortcut { ctx.registry.add(w.connectSearchShortcut { _ in onSearchShortcut() }) }
|
|
if let onShowHidden { ctx.registry.add(w.connectShowHidden { _ in onShowHidden() }) }
|
|
if let onUpFolder { ctx.registry.add(w.connectUpFolder { _ in onUpFolder() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension FileChooserWidget: WidgetView {
|
|
public typealias Target = Gtk.FileChooserWidget
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.FileChooserWidget, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension FileChooserWidget: Mountable {
|
|
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
|
|
let w = make(ctx)
|
|
for step in configure { step(w, ctx) }
|
|
return w
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension | source: Gtk.FileChooserWidget
|
|
/// Modifiers for `Gtk.FileChooserWidget`, available on every Portico view whose
|
|
/// backing widget is `Gtk.FileChooserWidget` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.FileChooserWidget {
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectDesktopFolder(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser show the user's Desktop
|
|
/// folder in the file list.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>D</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `desktop-folder` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onDesktopFolder(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectDesktopFolder { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectDownFolder(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser go to a child of the
|
|
/// current folder in the file hierarchy. The subfolder that will
|
|
/// be used is displayed in the path bar widget of the file chooser.
|
|
/// For example, if the path bar is showing "/foo/bar/baz", with bar
|
|
/// currently displayed, then this will cause the file chooser to
|
|
/// switch to the "baz" subfolder.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Down</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `down-folder` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onDownFolder(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectDownFolder { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectHomeFolder(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser show the user's home
|
|
/// folder in the file list.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Home</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `home-folder` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onHomeFolder(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectHomeFolder { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectLocationPopup(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser show a "Location" prompt which
|
|
/// the user can use to manually type the name of the file he wishes to select.
|
|
///
|
|
/// The default bindings for this signal are <kbd>Control</kbd>-<kbd>L</kbd>
|
|
/// with a `path` string of "" (the empty string). It is also bound to
|
|
/// <kbd>/</kbd> with a `path` string of "`/`" (a slash): this lets you
|
|
/// type `/` and immediately type a path name. On Unix systems, this is
|
|
/// bound to <kbd>~</kbd> (tilde) with a `path` string of "~" itself for
|
|
/// access to home directories.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `location-popup` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onLocationPopup(_ handler: @escaping (String) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectLocationPopup { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectLocationPopupOnPaste(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser show a "Location" prompt
|
|
/// when the user pastes into a `GtkFileChooserWidget`.
|
|
///
|
|
/// The default binding for this signal is <kbd>Control</kbd>-<kbd>V</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `location-popup-on-paste` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onLocationPopupOnPaste(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectLocationPopupOnPaste { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectLocationTogglePopup(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to toggle the visibility of a "Location" prompt
|
|
/// which the user can use to manually type the name of the file
|
|
/// he wishes to select.
|
|
///
|
|
/// The default binding for this signal is <kbd>Control</kbd>-<kbd>L</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `location-toggle-popup` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onLocationTogglePopup(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectLocationTogglePopup { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectPlacesShortcut(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to move the focus to the places sidebar.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>P</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `places-shortcut` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onPlacesShortcut(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectPlacesShortcut { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectQuickBookmark(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser switch to the bookmark
|
|
/// specified in the `bookmark_index` parameter. For example, if
|
|
/// you have three bookmarks, you can pass 0, 1, 2 to this signal
|
|
/// to switch to each of them, respectively.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>1</kbd>,
|
|
/// <kbd>Alt</kbd>-<kbd>2</kbd>, etc. until <kbd>Alt</kbd>-<kbd>0</kbd>.
|
|
/// Note that in the default binding, that <kbd>Alt</kbd>-<kbd>1</kbd> is
|
|
/// actually defined to switch to the bookmark at index 0, and so on
|
|
/// successively.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `quick-bookmark` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onQuickBookmark(_ handler: @escaping (Int32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectQuickBookmark { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectRecentShortcut(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser show the Recent location.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>R</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `recent-shortcut` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onRecentShortcut(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectRecentShortcut { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectSearchShortcut(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser show the search entry.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>S</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `search-shortcut` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onSearchShortcut(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectSearchShortcut { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectShowHidden(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser display hidden files.
|
|
///
|
|
/// The default binding for this signal is <kbd>Control</kbd>-<kbd>H</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `show-hidden` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onShowHidden(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectShowHidden { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FileChooserWidget.connectUpFolder(_:)
|
|
/// Emitted when the user asks for it.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// This is used to make the file chooser go to the parent
|
|
/// of the current folder in the file hierarchy.
|
|
///
|
|
/// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Up</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `up-folder` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onUpFolder(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectUpFolder { _ in handler() })
|
|
}
|
|
}
|
|
|
|
}
|