gtk/auto/file_chooser_button.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Align, BaselinePosition, Box, Buildable, Container, Dialog, FileChooser, FileChooserAction,
7 FileFilter, Orientable, Orientation, ResizeMode, Widget,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
15
16glib::wrapper! {
17 /// The [`FileChooserButton`][crate::FileChooserButton] is a widget that lets the user select a
18 /// file. It implements the [`FileChooser`][crate::FileChooser] interface. Visually, it is a
19 /// file name with a button to bring up a [`FileChooserDialog`][crate::FileChooserDialog].
20 /// The user can then use that dialog to change the file associated with
21 /// that button. This widget does not support setting the
22 /// [`select-multiple`][struct@crate::FileChooser#select-multiple] property to [`true`].
23 ///
24 /// ## Create a button to let the user select a file in /etc
25 ///
26 ///
27 ///
28 /// **⚠️ The following code is in C ⚠️**
29 ///
30 /// ```C
31 /// {
32 /// GtkWidget *button;
33 ///
34 /// button = gtk_file_chooser_button_new (_("Select a file"),
35 /// GTK_FILE_CHOOSER_ACTION_OPEN);
36 /// gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button),
37 /// "/etc");
38 /// }
39 /// ```
40 ///
41 /// The [`FileChooserButton`][crate::FileChooserButton] supports the `GtkFileChooserActions`
42 /// [`FileChooserAction::Open`][crate::FileChooserAction::Open] and [`FileChooserAction::SelectFolder`][crate::FileChooserAction::SelectFolder].
43 ///
44 /// > The [`FileChooserButton`][crate::FileChooserButton] will ellipsize the label, and will thus
45 /// > request little horizontal space. To give the button more space,
46 /// > you should call [`WidgetExt::preferred_size()`][crate::prelude::WidgetExt::preferred_size()],
47 /// > [`FileChooserButtonExt::set_width_chars()`][crate::prelude::FileChooserButtonExt::set_width_chars()], or pack the button in
48 /// > such a way that other interface elements give space to the
49 /// > widget.
50 ///
51 /// # CSS nodes
52 ///
53 /// GtkFileChooserButton has a CSS node with name “filechooserbutton”, containing
54 /// a subnode for the internal button with name “button” and style class “.file”.
55 ///
56 /// ## Properties
57 ///
58 ///
59 /// #### `dialog`
60 /// Instance of the [`FileChooserDialog`][crate::FileChooserDialog] associated with the button.
61 ///
62 /// Writeable | Construct Only
63 ///
64 ///
65 /// #### `title`
66 /// Title to put on the [`FileChooserDialog`][crate::FileChooserDialog] associated with the button.
67 ///
68 /// Readable | Writeable
69 ///
70 ///
71 /// #### `width-chars`
72 /// The width of the entry and label inside the button, in characters.
73 ///
74 /// Readable | Writeable
75 /// <details><summary><h4>Box</h4></summary>
76 ///
77 ///
78 /// #### `baseline-position`
79 /// Readable | Writeable
80 ///
81 ///
82 /// #### `homogeneous`
83 /// Readable | Writeable
84 ///
85 ///
86 /// #### `spacing`
87 /// Readable | Writeable
88 /// </details>
89 /// <details><summary><h4>Container</h4></summary>
90 ///
91 ///
92 /// #### `border-width`
93 /// Readable | Writeable
94 ///
95 ///
96 /// #### `child`
97 /// Writeable
98 ///
99 ///
100 /// #### `resize-mode`
101 /// Readable | Writeable
102 /// </details>
103 /// <details><summary><h4>Widget</h4></summary>
104 ///
105 ///
106 /// #### `app-paintable`
107 /// Readable | Writeable
108 ///
109 ///
110 /// #### `can-default`
111 /// Readable | Writeable
112 ///
113 ///
114 /// #### `can-focus`
115 /// Readable | Writeable
116 ///
117 ///
118 /// #### `composite-child`
119 /// Readable
120 ///
121 ///
122 /// #### `double-buffered`
123 /// Whether the widget is double buffered.
124 ///
125 /// Readable | Writeable
126 ///
127 ///
128 /// #### `events`
129 /// Readable | Writeable
130 ///
131 ///
132 /// #### `expand`
133 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
134 ///
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `focus-on-click`
139 /// Whether the widget should grab focus when it is clicked with the mouse.
140 ///
141 /// This property is only relevant for widgets that can take focus.
142 ///
143 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
144 /// GtkComboBox) implemented this property individually.
145 ///
146 /// Readable | Writeable
147 ///
148 ///
149 /// #### `halign`
150 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
151 ///
152 /// Readable | Writeable
153 ///
154 ///
155 /// #### `has-default`
156 /// Readable | Writeable
157 ///
158 ///
159 /// #### `has-focus`
160 /// Readable | Writeable
161 ///
162 ///
163 /// #### `has-tooltip`
164 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
165 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
166 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
167 /// whether it will provide a tooltip or not.
168 ///
169 /// Note that setting this property to [`true`] for the first time will change
170 /// the event masks of the GdkWindows of this widget to include leave-notify
171 /// and motion-notify events. This cannot and will not be undone when the
172 /// property is set to [`false`] again.
173 ///
174 /// Readable | Writeable
175 ///
176 ///
177 /// #### `height-request`
178 /// Readable | Writeable
179 ///
180 ///
181 /// #### `hexpand`
182 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
183 ///
184 /// Readable | Writeable
185 ///
186 ///
187 /// #### `hexpand-set`
188 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
189 ///
190 /// Readable | Writeable
191 ///
192 ///
193 /// #### `is-focus`
194 /// Readable | Writeable
195 ///
196 ///
197 /// #### `margin`
198 /// Sets all four sides' margin at once. If read, returns max
199 /// margin on any side.
200 ///
201 /// Readable | Writeable
202 ///
203 ///
204 /// #### `margin-bottom`
205 /// Margin on bottom side of widget.
206 ///
207 /// This property adds margin outside of the widget's normal size
208 /// request, the margin will be added in addition to the size from
209 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
210 ///
211 /// Readable | Writeable
212 ///
213 ///
214 /// #### `margin-end`
215 /// Margin on end of widget, horizontally. This property supports
216 /// left-to-right and right-to-left text directions.
217 ///
218 /// This property adds margin outside of the widget's normal size
219 /// request, the margin will be added in addition to the size from
220 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `margin-left`
226 /// Margin on left side of widget.
227 ///
228 /// This property adds margin outside of the widget's normal size
229 /// request, the margin will be added in addition to the size from
230 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
231 ///
232 /// Readable | Writeable
233 ///
234 ///
235 /// #### `margin-right`
236 /// Margin on right side of widget.
237 ///
238 /// This property adds margin outside of the widget's normal size
239 /// request, the margin will be added in addition to the size from
240 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
241 ///
242 /// Readable | Writeable
243 ///
244 ///
245 /// #### `margin-start`
246 /// Margin on start of widget, horizontally. This property supports
247 /// left-to-right and right-to-left text directions.
248 ///
249 /// This property adds margin outside of the widget's normal size
250 /// request, the margin will be added in addition to the size from
251 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
252 ///
253 /// Readable | Writeable
254 ///
255 ///
256 /// #### `margin-top`
257 /// Margin on top side of widget.
258 ///
259 /// This property adds margin outside of the widget's normal size
260 /// request, the margin will be added in addition to the size from
261 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
262 ///
263 /// Readable | Writeable
264 ///
265 ///
266 /// #### `name`
267 /// Readable | Writeable
268 ///
269 ///
270 /// #### `no-show-all`
271 /// Readable | Writeable
272 ///
273 ///
274 /// #### `opacity`
275 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
276 /// more details about window opacity.
277 ///
278 /// Before 3.8 this was only available in GtkWindow
279 ///
280 /// Readable | Writeable
281 ///
282 ///
283 /// #### `parent`
284 /// Readable | Writeable
285 ///
286 ///
287 /// #### `receives-default`
288 /// Readable | Writeable
289 ///
290 ///
291 /// #### `scale-factor`
292 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
293 /// more details about widget scaling.
294 ///
295 /// Readable
296 ///
297 ///
298 /// #### `sensitive`
299 /// Readable | Writeable
300 ///
301 ///
302 /// #### `style`
303 /// The style of the widget, which contains information about how it will look (colors, etc).
304 ///
305 /// Readable | Writeable
306 ///
307 ///
308 /// #### `tooltip-markup`
309 /// Sets the text of tooltip to be the given string, which is marked up
310 /// with the [Pango text markup language][PangoMarkupFormat].
311 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
312 ///
313 /// This is a convenience property which will take care of getting the
314 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
315 /// will automatically be set to [`true`] and there will be taken care of
316 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
317 ///
318 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
319 /// are set, the last one wins.
320 ///
321 /// Readable | Writeable
322 ///
323 ///
324 /// #### `tooltip-text`
325 /// Sets the text of tooltip to be the given string.
326 ///
327 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
328 ///
329 /// This is a convenience property which will take care of getting the
330 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
331 /// will automatically be set to [`true`] and there will be taken care of
332 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
333 ///
334 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
335 /// are set, the last one wins.
336 ///
337 /// Readable | Writeable
338 ///
339 ///
340 /// #### `valign`
341 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
342 ///
343 /// Readable | Writeable
344 ///
345 ///
346 /// #### `vexpand`
347 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
348 ///
349 /// Readable | Writeable
350 ///
351 ///
352 /// #### `vexpand-set`
353 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
354 ///
355 /// Readable | Writeable
356 ///
357 ///
358 /// #### `visible`
359 /// Readable | Writeable
360 ///
361 ///
362 /// #### `width-request`
363 /// Readable | Writeable
364 ///
365 ///
366 /// #### `window`
367 /// The widget's window if it is realized, [`None`] otherwise.
368 ///
369 /// Readable
370 /// </details>
371 /// <details><summary><h4>Orientable</h4></summary>
372 ///
373 ///
374 /// #### `orientation`
375 /// The orientation of the orientable.
376 ///
377 /// Readable | Writeable
378 /// </details>
379 /// <details><summary><h4>FileChooser</h4></summary>
380 ///
381 ///
382 /// #### `action`
383 /// Readable | Writeable
384 ///
385 ///
386 /// #### `create-folders`
387 /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
388 /// will offer the user to create new folders.
389 ///
390 /// Readable | Writeable
391 ///
392 ///
393 /// #### `do-overwrite-confirmation`
394 /// Whether a file chooser in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode
395 /// will present an overwrite confirmation dialog if the user
396 /// selects a file name that already exists.
397 ///
398 /// Readable | Writeable
399 ///
400 ///
401 /// #### `extra-widget`
402 /// Readable | Writeable
403 ///
404 ///
405 /// #### `filter`
406 /// Readable | Writeable
407 ///
408 ///
409 /// #### `local-only`
410 /// Readable | Writeable
411 ///
412 ///
413 /// #### `preview-widget`
414 /// Readable | Writeable
415 ///
416 ///
417 /// #### `preview-widget-active`
418 /// Readable | Writeable
419 ///
420 ///
421 /// #### `select-multiple`
422 /// Readable | Writeable
423 ///
424 ///
425 /// #### `show-hidden`
426 /// Readable | Writeable
427 ///
428 ///
429 /// #### `use-preview-label`
430 /// Readable | Writeable
431 /// </details>
432 ///
433 /// ## Signals
434 ///
435 ///
436 /// #### `file-set`
437 /// The ::file-set signal is emitted when the user selects a file.
438 ///
439 /// Note that this signal is only emitted when the user
440 /// changes the file.
441 ///
442 ///
443 /// <details><summary><h4>Container</h4></summary>
444 ///
445 ///
446 /// #### `add`
447 ///
448 ///
449 ///
450 /// #### `check-resize`
451 ///
452 ///
453 ///
454 /// #### `remove`
455 ///
456 ///
457 ///
458 /// #### `set-focus-child`
459 ///
460 /// </details>
461 /// <details><summary><h4>Widget</h4></summary>
462 ///
463 ///
464 /// #### `accel-closures-changed`
465 ///
466 ///
467 ///
468 /// #### `button-press-event`
469 /// The ::button-press-event signal will be emitted when a button
470 /// (typically from a mouse) is pressed.
471 ///
472 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
473 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
474 ///
475 /// This signal will be sent to the grab widget if there is one.
476 ///
477 ///
478 ///
479 ///
480 /// #### `button-release-event`
481 /// The ::button-release-event signal will be emitted when a button
482 /// (typically from a mouse) is released.
483 ///
484 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
485 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
486 ///
487 /// This signal will be sent to the grab widget if there is one.
488 ///
489 ///
490 ///
491 ///
492 /// #### `can-activate-accel`
493 /// Determines whether an accelerator that activates the signal
494 /// identified by `signal_id` can currently be activated.
495 /// This signal is present to allow applications and derived
496 /// widgets to override the default [`Widget`][crate::Widget] handling
497 /// for determining whether an accelerator can be activated.
498 ///
499 ///
500 ///
501 ///
502 /// #### `child-notify`
503 /// The ::child-notify signal is emitted for each
504 /// [child property][child-properties] that has
505 /// changed on an object. The signal's detail holds the property name.
506 ///
507 /// Detailed
508 ///
509 ///
510 /// #### `composited-changed`
511 /// The ::composited-changed signal is emitted when the composited
512 /// status of `widgets` screen changes.
513 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
514 ///
515 /// Action
516 ///
517 ///
518 /// #### `configure-event`
519 /// The ::configure-event signal will be emitted when the size, position or
520 /// stacking of the `widget`'s window has changed.
521 ///
522 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
523 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
524 /// automatically for all new windows.
525 ///
526 ///
527 ///
528 ///
529 /// #### `damage-event`
530 /// Emitted when a redirected window belonging to `widget` gets drawn into.
531 /// The region/area members of the event shows what area of the redirected
532 /// drawable was drawn into.
533 ///
534 ///
535 ///
536 ///
537 /// #### `delete-event`
538 /// The ::delete-event signal is emitted if a user requests that
539 /// a toplevel window is closed. The default handler for this signal
540 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
541 /// this signal will cause the window to be hidden instead, so that
542 /// it can later be shown again without reconstructing it.
543 ///
544 ///
545 ///
546 ///
547 /// #### `destroy`
548 /// Signals that all holders of a reference to the widget should release
549 /// the reference that they hold. May result in finalization of the widget
550 /// if all references are released.
551 ///
552 /// This signal is not suitable for saving widget state.
553 ///
554 ///
555 ///
556 ///
557 /// #### `destroy-event`
558 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
559 /// You rarely get this signal, because most widgets disconnect themselves
560 /// from their window before they destroy it, so no widget owns the
561 /// window at destroy time.
562 ///
563 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
564 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
565 /// automatically for all new windows.
566 ///
567 ///
568 ///
569 ///
570 /// #### `direction-changed`
571 /// The ::direction-changed signal is emitted when the text direction
572 /// of a widget changes.
573 ///
574 ///
575 ///
576 ///
577 /// #### `drag-begin`
578 /// The ::drag-begin signal is emitted on the drag source when a drag is
579 /// started. A typical reason to connect to this signal is to set up a
580 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
581 ///
582 /// Note that some widgets set up a drag icon in the default handler of
583 /// this signal, so you may have to use `g_signal_connect_after()` to
584 /// override what the default handler did.
585 ///
586 ///
587 ///
588 ///
589 /// #### `drag-data-delete`
590 /// The ::drag-data-delete signal is emitted on the drag source when a drag
591 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
592 /// handler is responsible for deleting the data that has been dropped. What
593 /// "delete" means depends on the context of the drag operation.
594 ///
595 ///
596 ///
597 ///
598 /// #### `drag-data-get`
599 /// The ::drag-data-get signal is emitted on the drag source when the drop
600 /// site requests the data which is dragged. It is the responsibility of
601 /// the signal handler to fill `data` with the data in the format which
602 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
603 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
604 ///
605 ///
606 ///
607 ///
608 /// #### `drag-data-received`
609 /// The ::drag-data-received signal is emitted on the drop site when the
610 /// dragged data has been received. If the data was received in order to
611 /// determine whether the drop will be accepted, the handler is expected
612 /// to call `gdk_drag_status()` and not finish the drag.
613 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
614 /// (and this is the last target to be received), the handler for this
615 /// signal is expected to process the received data and then call
616 /// `gtk_drag_finish()`, setting the `success` parameter depending on
617 /// whether the data was processed successfully.
618 ///
619 /// Applications must create some means to determine why the signal was emitted
620 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
621 ///
622 /// The handler may inspect the selected action with
623 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
624 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
625 /// shown in the following example:
626 ///
627 ///
628 /// **⚠️ The following code is in C ⚠️**
629 ///
630 /// ```C
631 /// void
632 /// drag_data_received (GtkWidget *widget,
633 /// GdkDragContext *context,
634 /// gint x,
635 /// gint y,
636 /// GtkSelectionData *data,
637 /// guint info,
638 /// guint time)
639 /// {
640 /// if ((data->length >= 0) && (data->format == 8))
641 /// {
642 /// GdkDragAction action;
643 ///
644 /// // handle data here
645 ///
646 /// action = gdk_drag_context_get_selected_action (context);
647 /// if (action == GDK_ACTION_ASK)
648 /// {
649 /// GtkWidget *dialog;
650 /// gint response;
651 ///
652 /// dialog = gtk_message_dialog_new (NULL,
653 /// GTK_DIALOG_MODAL |
654 /// GTK_DIALOG_DESTROY_WITH_PARENT,
655 /// GTK_MESSAGE_INFO,
656 /// GTK_BUTTONS_YES_NO,
657 /// "Move the data ?\n");
658 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
659 /// gtk_widget_destroy (dialog);
660 ///
661 /// if (response == GTK_RESPONSE_YES)
662 /// action = GDK_ACTION_MOVE;
663 /// else
664 /// action = GDK_ACTION_COPY;
665 /// }
666 ///
667 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
668 /// }
669 /// else
670 /// gtk_drag_finish (context, FALSE, FALSE, time);
671 /// }
672 /// ```
673 ///
674 ///
675 ///
676 ///
677 /// #### `drag-drop`
678 /// The ::drag-drop signal is emitted on the drop site when the user drops
679 /// the data onto the widget. The signal handler must determine whether
680 /// the cursor position is in a drop zone or not. If it is not in a drop
681 /// zone, it returns [`false`] and no further processing is necessary.
682 /// Otherwise, the handler returns [`true`]. In this case, the handler must
683 /// ensure that `gtk_drag_finish()` is called to let the source know that
684 /// the drop is done. The call to `gtk_drag_finish()` can be done either
685 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
686 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
687 /// or more of the supported targets.
688 ///
689 ///
690 ///
691 ///
692 /// #### `drag-end`
693 /// The ::drag-end signal is emitted on the drag source when a drag is
694 /// finished. A typical reason to connect to this signal is to undo
695 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
696 ///
697 ///
698 ///
699 ///
700 /// #### `drag-failed`
701 /// The ::drag-failed signal is emitted on the drag source when a drag has
702 /// failed. The signal handler may hook custom code to handle a failed DnD
703 /// operation based on the type of error, it returns [`true`] is the failure has
704 /// been already handled (not showing the default "drag operation failed"
705 /// animation), otherwise it returns [`false`].
706 ///
707 ///
708 ///
709 ///
710 /// #### `drag-leave`
711 /// The ::drag-leave signal is emitted on the drop site when the cursor
712 /// leaves the widget. A typical reason to connect to this signal is to
713 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
714 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
715 ///
716 ///
717 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
718 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
719 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
720 ///
721 ///
722 ///
723 ///
724 /// #### `drag-motion`
725 /// The ::drag-motion signal is emitted on the drop site when the user
726 /// moves the cursor over the widget during a drag. The signal handler
727 /// must determine whether the cursor position is in a drop zone or not.
728 /// If it is not in a drop zone, it returns [`false`] and no further processing
729 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
730 /// handler is responsible for providing the necessary information for
731 /// displaying feedback to the user, by calling `gdk_drag_status()`.
732 ///
733 /// If the decision whether the drop will be accepted or rejected can't be
734 /// made based solely on the cursor position and the type of the data, the
735 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
736 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
737 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
738 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
739 /// when using the drag-motion signal that way.
740 ///
741 /// Also note that there is no drag-enter signal. The drag receiver has to
742 /// keep track of whether he has received any drag-motion signals since the
743 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
744 /// an "enter" signal. Upon an "enter", the handler will typically highlight
745 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
746 ///
747 ///
748 /// **⚠️ The following code is in C ⚠️**
749 ///
750 /// ```C
751 /// static void
752 /// drag_motion (GtkWidget *widget,
753 /// GdkDragContext *context,
754 /// gint x,
755 /// gint y,
756 /// guint time)
757 /// {
758 /// GdkAtom target;
759 ///
760 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
761 ///
762 /// if (!private_data->drag_highlight)
763 /// {
764 /// private_data->drag_highlight = 1;
765 /// gtk_drag_highlight (widget);
766 /// }
767 ///
768 /// target = gtk_drag_dest_find_target (widget, context, NULL);
769 /// if (target == GDK_NONE)
770 /// gdk_drag_status (context, 0, time);
771 /// else
772 /// {
773 /// private_data->pending_status
774 /// = gdk_drag_context_get_suggested_action (context);
775 /// gtk_drag_get_data (widget, context, target, time);
776 /// }
777 ///
778 /// return TRUE;
779 /// }
780 ///
781 /// static void
782 /// drag_data_received (GtkWidget *widget,
783 /// GdkDragContext *context,
784 /// gint x,
785 /// gint y,
786 /// GtkSelectionData *selection_data,
787 /// guint info,
788 /// guint time)
789 /// {
790 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
791 ///
792 /// if (private_data->suggested_action)
793 /// {
794 /// private_data->suggested_action = 0;
795 ///
796 /// // We are getting this data due to a request in drag_motion,
797 /// // rather than due to a request in drag_drop, so we are just
798 /// // supposed to call gdk_drag_status(), not actually paste in
799 /// // the data.
800 ///
801 /// str = gtk_selection_data_get_text (selection_data);
802 /// if (!data_is_acceptable (str))
803 /// gdk_drag_status (context, 0, time);
804 /// else
805 /// gdk_drag_status (context,
806 /// private_data->suggested_action,
807 /// time);
808 /// }
809 /// else
810 /// {
811 /// // accept the drop
812 /// }
813 /// }
814 /// ```
815 ///
816 ///
817 ///
818 ///
819 /// #### `draw`
820 /// This signal is emitted when a widget is supposed to render itself.
821 /// The `widget`'s top left corner must be painted at the origin of
822 /// the passed in context and be sized to the values returned by
823 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
824 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
825 ///
826 /// Signal handlers connected to this signal can modify the cairo
827 /// context passed as `cr` in any way they like and don't need to
828 /// restore it. The signal emission takes care of calling `cairo_save()`
829 /// before and `cairo_restore()` after invoking the handler.
830 ///
831 /// The signal handler will get a `cr` with a clip region already set to the
832 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
833 /// widgets that want to avoid redrawing themselves completely can get the full
834 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
835 /// get a finer-grained representation of the dirty region with
836 /// `cairo_copy_clip_rectangle_list()`.
837 ///
838 ///
839 ///
840 ///
841 /// #### `enter-notify-event`
842 /// The ::enter-notify-event will be emitted when the pointer enters
843 /// the `widget`'s window.
844 ///
845 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
846 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
847 ///
848 /// This signal will be sent to the grab widget if there is one.
849 ///
850 ///
851 ///
852 ///
853 /// #### `event`
854 /// The GTK+ main loop will emit three signals for each GDK event delivered
855 /// to a widget: one generic ::event signal, another, more specific,
856 /// signal that matches the type of event delivered (e.g.
857 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
858 /// [`event-after`][struct@crate::Widget#event-after] signal.
859 ///
860 ///
861 ///
862 ///
863 /// #### `event-after`
864 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
865 /// the second more specific signal, ::event-after will be emitted
866 /// regardless of the previous two signals handlers return values.
867 ///
868 ///
869 ///
870 ///
871 /// #### `focus`
872 ///
873 ///
874 ///
875 /// #### `focus-in-event`
876 /// The ::focus-in-event signal will be emitted when the keyboard focus
877 /// enters the `widget`'s window.
878 ///
879 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
880 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
881 ///
882 ///
883 ///
884 ///
885 /// #### `focus-out-event`
886 /// The ::focus-out-event signal will be emitted when the keyboard focus
887 /// leaves the `widget`'s window.
888 ///
889 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
890 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
891 ///
892 ///
893 ///
894 ///
895 /// #### `grab-broken-event`
896 /// Emitted when a pointer or keyboard grab on a window belonging
897 /// to `widget` gets broken.
898 ///
899 /// On X11, this happens when the grab window becomes unviewable
900 /// (i.e. it or one of its ancestors is unmapped), or if the same
901 /// application grabs the pointer or keyboard again.
902 ///
903 ///
904 ///
905 ///
906 /// #### `grab-focus`
907 /// Action
908 ///
909 ///
910 /// #### `grab-notify`
911 /// The ::grab-notify signal is emitted when a widget becomes
912 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
913 /// another widget, or when it becomes unshadowed due to a grab
914 /// being removed.
915 ///
916 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
917 /// grab widget in the grab stack of its window group is not
918 /// its ancestor.
919 ///
920 ///
921 ///
922 ///
923 /// #### `hide`
924 /// The ::hide signal is emitted when `widget` is hidden, for example with
925 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
926 ///
927 ///
928 ///
929 ///
930 /// #### `hierarchy-changed`
931 /// The ::hierarchy-changed signal is emitted when the
932 /// anchored state of a widget changes. A widget is
933 /// “anchored” when its toplevel
934 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
935 /// a widget changes from un-anchored to anchored or vice-versa.
936 ///
937 ///
938 ///
939 ///
940 /// #### `key-press-event`
941 /// The ::key-press-event signal is emitted when a key is pressed. The signal
942 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
943 ///
944 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
945 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
946 ///
947 /// This signal will be sent to the grab widget if there is one.
948 ///
949 ///
950 ///
951 ///
952 /// #### `key-release-event`
953 /// The ::key-release-event signal is emitted when a key is released.
954 ///
955 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
956 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
957 ///
958 /// This signal will be sent to the grab widget if there is one.
959 ///
960 ///
961 ///
962 ///
963 /// #### `keynav-failed`
964 /// Gets emitted if keyboard navigation fails.
965 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
966 ///
967 ///
968 ///
969 ///
970 /// #### `leave-notify-event`
971 /// The ::leave-notify-event will be emitted when the pointer leaves
972 /// the `widget`'s window.
973 ///
974 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
975 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
976 ///
977 /// This signal will be sent to the grab widget if there is one.
978 ///
979 ///
980 ///
981 ///
982 /// #### `map`
983 /// The ::map signal is emitted when `widget` is going to be mapped, that is
984 /// when the widget is visible (which is controlled with
985 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
986 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
987 /// be emitted.
988 ///
989 /// The ::map signal can be used to determine whether a widget will be drawn,
990 /// for instance it can resume an animation that was stopped during the
991 /// emission of [`unmap`][struct@crate::Widget#unmap].
992 ///
993 ///
994 ///
995 ///
996 /// #### `map-event`
997 /// The ::map-event signal will be emitted when the `widget`'s window is
998 /// mapped. A window is mapped when it becomes visible on the screen.
999 ///
1000 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1001 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1002 /// automatically for all new windows.
1003 ///
1004 ///
1005 ///
1006 ///
1007 /// #### `mnemonic-activate`
1008 /// The default handler for this signal activates `widget` if `group_cycling`
1009 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1010 ///
1011 ///
1012 ///
1013 ///
1014 /// #### `motion-notify-event`
1015 /// The ::motion-notify-event signal is emitted when the pointer moves
1016 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1017 ///
1018 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1019 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1020 ///
1021 /// This signal will be sent to the grab widget if there is one.
1022 ///
1023 ///
1024 ///
1025 ///
1026 /// #### `move-focus`
1027 /// Action
1028 ///
1029 ///
1030 /// #### `parent-set`
1031 /// The ::parent-set signal is emitted when a new parent
1032 /// has been set on a widget.
1033 ///
1034 ///
1035 ///
1036 ///
1037 /// #### `popup-menu`
1038 /// This signal gets emitted whenever a widget should pop up a context
1039 /// menu. This usually happens through the standard key binding mechanism;
1040 /// by pressing a certain key while a widget is focused, the user can cause
1041 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1042 /// a menu with clipboard commands. See the
1043 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1044 /// for an example of how to use this signal.
1045 ///
1046 /// Action
1047 ///
1048 ///
1049 /// #### `property-notify-event`
1050 /// The ::property-notify-event signal will be emitted when a property on
1051 /// the `widget`'s window has been changed or deleted.
1052 ///
1053 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1054 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1055 ///
1056 ///
1057 ///
1058 ///
1059 /// #### `proximity-in-event`
1060 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1061 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1062 ///
1063 /// This signal will be sent to the grab widget if there is one.
1064 ///
1065 ///
1066 ///
1067 ///
1068 /// #### `proximity-out-event`
1069 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1070 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1071 ///
1072 /// This signal will be sent to the grab widget if there is one.
1073 ///
1074 ///
1075 ///
1076 ///
1077 /// #### `query-tooltip`
1078 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1079 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1080 /// focus in keyboard mode.
1081 ///
1082 /// Using the given coordinates, the signal handler should determine
1083 /// whether a tooltip should be shown for `widget`. If this is the case
1084 /// [`true`] should be returned, [`false`] otherwise. Note that if
1085 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1086 /// should not be used.
1087 ///
1088 /// The signal handler is free to manipulate `tooltip` with the therefore
1089 /// destined function calls.
1090 ///
1091 ///
1092 ///
1093 ///
1094 /// #### `realize`
1095 /// The ::realize signal is emitted when `widget` is associated with a
1096 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1097 /// widget has been mapped (that is, it is going to be drawn).
1098 ///
1099 ///
1100 ///
1101 ///
1102 /// #### `screen-changed`
1103 /// The ::screen-changed signal gets emitted when the
1104 /// screen of a widget has changed.
1105 ///
1106 ///
1107 ///
1108 ///
1109 /// #### `scroll-event`
1110 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1111 /// range is pressed. Wheel mice are usually configured to generate
1112 /// button press events for buttons 4 and 5 when the wheel is turned.
1113 ///
1114 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1115 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1116 ///
1117 /// This signal will be sent to the grab widget if there is one.
1118 ///
1119 ///
1120 ///
1121 ///
1122 /// #### `selection-clear-event`
1123 /// The ::selection-clear-event signal will be emitted when the
1124 /// the `widget`'s window has lost ownership of a selection.
1125 ///
1126 ///
1127 ///
1128 ///
1129 /// #### `selection-get`
1130 ///
1131 ///
1132 ///
1133 /// #### `selection-notify-event`
1134 ///
1135 ///
1136 ///
1137 /// #### `selection-received`
1138 ///
1139 ///
1140 ///
1141 /// #### `selection-request-event`
1142 /// The ::selection-request-event signal will be emitted when
1143 /// another client requests ownership of the selection owned by
1144 /// the `widget`'s window.
1145 ///
1146 ///
1147 ///
1148 ///
1149 /// #### `show`
1150 /// The ::show signal is emitted when `widget` is shown, for example with
1151 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1152 ///
1153 ///
1154 ///
1155 ///
1156 /// #### `show-help`
1157 /// Action
1158 ///
1159 ///
1160 /// #### `size-allocate`
1161 ///
1162 ///
1163 ///
1164 /// #### `state-changed`
1165 /// The ::state-changed signal is emitted when the widget state changes.
1166 /// See `gtk_widget_get_state()`.
1167 ///
1168 ///
1169 ///
1170 ///
1171 /// #### `state-flags-changed`
1172 /// The ::state-flags-changed signal is emitted when the widget state
1173 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1174 ///
1175 ///
1176 ///
1177 ///
1178 /// #### `style-set`
1179 /// The ::style-set signal is emitted when a new style has been set
1180 /// on a widget. Note that style-modifying functions like
1181 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1182 ///
1183 /// Note that this signal is emitted for changes to the deprecated
1184 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1185 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1186 ///
1187 ///
1188 ///
1189 ///
1190 /// #### `style-updated`
1191 /// The ::style-updated signal is a convenience signal that is emitted when the
1192 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1193 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1194 ///
1195 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1196 /// cause this signal to be emitted.
1197 ///
1198 ///
1199 ///
1200 ///
1201 /// #### `touch-event`
1202 ///
1203 ///
1204 ///
1205 /// #### `unmap`
1206 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1207 /// means that either it or any of its parents up to the toplevel widget have
1208 /// been set as hidden.
1209 ///
1210 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1211 /// used to, for example, stop an animation on the widget.
1212 ///
1213 ///
1214 ///
1215 ///
1216 /// #### `unmap-event`
1217 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1218 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1219 ///
1220 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1221 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1222 /// automatically for all new windows.
1223 ///
1224 ///
1225 ///
1226 ///
1227 /// #### `unrealize`
1228 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1229 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1230 /// called or the widget has been unmapped (that is, it is going to be
1231 /// hidden).
1232 ///
1233 ///
1234 ///
1235 ///
1236 /// #### `visibility-notify-event`
1237 /// The ::visibility-notify-event will be emitted when the `widget`'s
1238 /// window is obscured or unobscured.
1239 ///
1240 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1241 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1242 ///
1243 ///
1244 ///
1245 ///
1246 /// #### `window-state-event`
1247 /// The ::window-state-event will be emitted when the state of the
1248 /// toplevel window associated to the `widget` changes.
1249 ///
1250 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1251 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1252 /// this mask automatically for all new windows.
1253 ///
1254 ///
1255 /// </details>
1256 /// <details><summary><h4>FileChooser</h4></summary>
1257 ///
1258 ///
1259 /// #### `confirm-overwrite`
1260 /// This signal gets emitted whenever it is appropriate to present a
1261 /// confirmation dialog when the user has selected a file name that
1262 /// already exists. The signal only gets emitted when the file
1263 /// chooser is in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode.
1264 ///
1265 /// Most applications just need to turn on the
1266 /// [`do-overwrite-confirmation`][struct@crate::FileChooser#do-overwrite-confirmation] property (or call the
1267 /// [`FileChooserExt::set_do_overwrite_confirmation()`][crate::prelude::FileChooserExt::set_do_overwrite_confirmation()] function), and
1268 /// they will automatically get a stock confirmation dialog.
1269 /// Applications which need to customize this behavior should do
1270 /// that, and also connect to the [`confirm-overwrite`][struct@crate::FileChooser#confirm-overwrite]
1271 /// signal.
1272 ///
1273 /// A signal handler for this signal must return a
1274 /// [`FileChooserConfirmation`][crate::FileChooserConfirmation] value, which indicates the action to
1275 /// take. If the handler determines that the user wants to select a
1276 /// different filename, it should return
1277 /// [`FileChooserConfirmation::SelectAgain`][crate::FileChooserConfirmation::SelectAgain]. If it determines
1278 /// that the user is satisfied with his choice of file name, it
1279 /// should return [`FileChooserConfirmation::AcceptFilename`][crate::FileChooserConfirmation::AcceptFilename].
1280 /// On the other hand, if it determines that the stock confirmation
1281 /// dialog should be used, it should return
1282 /// [`FileChooserConfirmation::Confirm`][crate::FileChooserConfirmation::Confirm]. The following example
1283 /// illustrates this.
1284 ///
1285 /// ## Custom confirmation ## {`gtkfilechooser`-confirmation}
1286 ///
1287 ///
1288 ///
1289 /// **⚠️ The following code is in C ⚠️**
1290 ///
1291 /// ```C
1292 /// static GtkFileChooserConfirmation
1293 /// confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
1294 /// {
1295 /// char *uri;
1296 ///
1297 /// uri = gtk_file_chooser_get_uri (chooser);
1298 ///
1299 /// if (is_uri_read_only (uri))
1300 /// {
1301 /// if (user_wants_to_replace_read_only_file (uri))
1302 /// return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
1303 /// else
1304 /// return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
1305 /// } else
1306 /// return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
1307 /// }
1308 ///
1309 /// ...
1310 ///
1311 /// chooser = gtk_file_chooser_dialog_new (...);
1312 ///
1313 /// gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
1314 /// g_signal_connect (chooser, "confirm-overwrite",
1315 /// G_CALLBACK (confirm_overwrite_callback), NULL);
1316 ///
1317 /// if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
1318 /// save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
1319 ///
1320 /// gtk_widget_destroy (chooser);
1321 /// ```
1322 ///
1323 ///
1324 ///
1325 ///
1326 /// #### `current-folder-changed`
1327 /// This signal is emitted when the current folder in a [`FileChooser`][crate::FileChooser]
1328 /// changes. This can happen due to the user performing some action that
1329 /// changes folders, such as selecting a bookmark or visiting a folder on the
1330 /// file list. It can also happen as a result of calling a function to
1331 /// explicitly change the current folder in a file chooser.
1332 ///
1333 /// Normally you do not need to connect to this signal, unless you need to keep
1334 /// track of which folder a file chooser is showing.
1335 ///
1336 /// See also: [`FileChooserExt::set_current_folder()`][crate::prelude::FileChooserExt::set_current_folder()],
1337 /// [`FileChooserExt::current_folder()`][crate::prelude::FileChooserExt::current_folder()],
1338 /// [`FileChooserExt::set_current_folder_uri()`][crate::prelude::FileChooserExt::set_current_folder_uri()],
1339 /// [`FileChooserExt::current_folder_uri()`][crate::prelude::FileChooserExt::current_folder_uri()].
1340 ///
1341 ///
1342 ///
1343 ///
1344 /// #### `file-activated`
1345 /// This signal is emitted when the user "activates" a file in the file
1346 /// chooser. This can happen by double-clicking on a file in the file list, or
1347 /// by pressing `Enter`.
1348 ///
1349 /// Normally you do not need to connect to this signal. It is used internally
1350 /// by [`FileChooserDialog`][crate::FileChooserDialog] to know when to activate the default button in the
1351 /// dialog.
1352 ///
1353 /// See also: [`FileChooserExt::filename()`][crate::prelude::FileChooserExt::filename()],
1354 /// [`FileChooserExt::filenames()`][crate::prelude::FileChooserExt::filenames()], [`FileChooserExt::uri()`][crate::prelude::FileChooserExt::uri()],
1355 /// [`FileChooserExt::uris()`][crate::prelude::FileChooserExt::uris()].
1356 ///
1357 ///
1358 ///
1359 ///
1360 /// #### `selection-changed`
1361 /// This signal is emitted when there is a change in the set of selected files
1362 /// in a [`FileChooser`][crate::FileChooser]. This can happen when the user modifies the selection
1363 /// with the mouse or the keyboard, or when explicitly calling functions to
1364 /// change the selection.
1365 ///
1366 /// Normally you do not need to connect to this signal, as it is easier to wait
1367 /// for the file chooser to finish running, and then to get the list of
1368 /// selected files using the functions mentioned below.
1369 ///
1370 /// See also: [`FileChooserExt::select_filename()`][crate::prelude::FileChooserExt::select_filename()],
1371 /// [`FileChooserExt::unselect_filename()`][crate::prelude::FileChooserExt::unselect_filename()], [`FileChooserExt::filename()`][crate::prelude::FileChooserExt::filename()],
1372 /// [`FileChooserExt::filenames()`][crate::prelude::FileChooserExt::filenames()], [`FileChooserExt::select_uri()`][crate::prelude::FileChooserExt::select_uri()],
1373 /// [`FileChooserExt::unselect_uri()`][crate::prelude::FileChooserExt::unselect_uri()], [`FileChooserExt::uri()`][crate::prelude::FileChooserExt::uri()],
1374 /// [`FileChooserExt::uris()`][crate::prelude::FileChooserExt::uris()].
1375 ///
1376 ///
1377 ///
1378 ///
1379 /// #### `update-preview`
1380 /// This signal is emitted when the preview in a file chooser should be
1381 /// regenerated. For example, this can happen when the currently selected file
1382 /// changes. You should use this signal if you want your file chooser to have
1383 /// a preview widget.
1384 ///
1385 /// Once you have installed a preview widget with
1386 /// [`FileChooserExt::set_preview_widget()`][crate::prelude::FileChooserExt::set_preview_widget()], you should update it when this
1387 /// signal is emitted. You can use the functions
1388 /// [`FileChooserExt::preview_filename()`][crate::prelude::FileChooserExt::preview_filename()] or
1389 /// [`FileChooserExt::preview_uri()`][crate::prelude::FileChooserExt::preview_uri()] to get the name of the file to preview.
1390 /// Your widget may not be able to preview all kinds of files; your callback
1391 /// must call [`FileChooserExt::set_preview_widget_active()`][crate::prelude::FileChooserExt::set_preview_widget_active()] to inform the file
1392 /// chooser about whether the preview was generated successfully or not.
1393 ///
1394 /// Please see the example code in
1395 /// [Using a Preview Widget][gtkfilechooser-preview].
1396 ///
1397 /// See also: [`FileChooserExt::set_preview_widget()`][crate::prelude::FileChooserExt::set_preview_widget()],
1398 /// [`FileChooserExt::set_preview_widget_active()`][crate::prelude::FileChooserExt::set_preview_widget_active()],
1399 /// [`FileChooserExt::set_use_preview_label()`][crate::prelude::FileChooserExt::set_use_preview_label()],
1400 /// [`FileChooserExt::preview_filename()`][crate::prelude::FileChooserExt::preview_filename()],
1401 /// [`FileChooserExt::preview_uri()`][crate::prelude::FileChooserExt::preview_uri()].
1402 ///
1403 ///
1404 /// </details>
1405 ///
1406 /// # Implements
1407 ///
1408 /// [`FileChooserButtonExt`][trait@crate::prelude::FileChooserButtonExt], [`BoxExt`][trait@crate::prelude::BoxExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`FileChooserExt`][trait@crate::prelude::FileChooserExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual], [`FileChooserExtManual`][trait@crate::prelude::FileChooserExtManual]
1409 #[doc(alias = "GtkFileChooserButton")]
1410 pub struct FileChooserButton(Object<ffi::GtkFileChooserButton, ffi::GtkFileChooserButtonClass>) @extends Box, Container, Widget, @implements Buildable, Orientable, FileChooser;
1411
1412 match fn {
1413 type_ => || ffi::gtk_file_chooser_button_get_type(),
1414 }
1415}
1416
1417impl FileChooserButton {
1418 pub const NONE: Option<&'static FileChooserButton> = None;
1419
1420 /// Creates a new file-selecting button widget.
1421 /// ## `title`
1422 /// the title of the browse dialog.
1423 /// ## `action`
1424 /// the open mode for the widget.
1425 ///
1426 /// # Returns
1427 ///
1428 /// a new button widget.
1429 #[doc(alias = "gtk_file_chooser_button_new")]
1430 pub fn new(title: &str, action: FileChooserAction) -> FileChooserButton {
1431 assert_initialized_main_thread!();
1432 unsafe {
1433 Widget::from_glib_none(ffi::gtk_file_chooser_button_new(
1434 title.to_glib_none().0,
1435 action.into_glib(),
1436 ))
1437 .unsafe_cast()
1438 }
1439 }
1440
1441 /// Creates a [`FileChooserButton`][crate::FileChooserButton] widget which uses `dialog` as its
1442 /// file-picking window.
1443 ///
1444 /// Note that `dialog` must be a [`Dialog`][crate::Dialog] (or subclass) which
1445 /// implements the [`FileChooser`][crate::FileChooser] interface and must not have
1446 /// [`DialogFlags::DESTROY_WITH_PARENT`][crate::DialogFlags::DESTROY_WITH_PARENT] set.
1447 ///
1448 /// Also note that the dialog needs to have its confirmative button
1449 /// added with response [`ResponseType::Accept`][crate::ResponseType::Accept] or [`ResponseType::Ok`][crate::ResponseType::Ok] in
1450 /// order for the button to take over the file selected in the dialog.
1451 /// ## `dialog`
1452 /// the widget to use as dialog
1453 ///
1454 /// # Returns
1455 ///
1456 /// a new button widget.
1457 #[doc(alias = "gtk_file_chooser_button_new_with_dialog")]
1458 #[doc(alias = "new_with_dialog")]
1459 pub fn with_dialog(dialog: &impl IsA<Dialog>) -> FileChooserButton {
1460 skip_assert_initialized!();
1461 unsafe {
1462 Widget::from_glib_none(ffi::gtk_file_chooser_button_new_with_dialog(
1463 dialog.as_ref().to_glib_none().0,
1464 ))
1465 .unsafe_cast()
1466 }
1467 }
1468
1469 // rustdoc-stripper-ignore-next
1470 /// Creates a new builder-pattern struct instance to construct [`FileChooserButton`] objects.
1471 ///
1472 /// This method returns an instance of [`FileChooserButtonBuilder`](crate::builders::FileChooserButtonBuilder) which can be used to create [`FileChooserButton`] objects.
1473 pub fn builder() -> FileChooserButtonBuilder {
1474 FileChooserButtonBuilder::new()
1475 }
1476}
1477
1478impl Default for FileChooserButton {
1479 fn default() -> Self {
1480 glib::object::Object::new::<Self>()
1481 }
1482}
1483
1484// rustdoc-stripper-ignore-next
1485/// A [builder-pattern] type to construct [`FileChooserButton`] objects.
1486///
1487/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1488#[must_use = "The builder must be built to be used"]
1489pub struct FileChooserButtonBuilder {
1490 builder: glib::object::ObjectBuilder<'static, FileChooserButton>,
1491}
1492
1493impl FileChooserButtonBuilder {
1494 fn new() -> Self {
1495 Self {
1496 builder: glib::object::Object::builder(),
1497 }
1498 }
1499
1500 /// Instance of the [`FileChooserDialog`][crate::FileChooserDialog] associated with the button.
1501 pub fn dialog(self, dialog: &impl IsA<FileChooser>) -> Self {
1502 Self {
1503 builder: self.builder.property("dialog", dialog.clone().upcast()),
1504 }
1505 }
1506
1507 /// Title to put on the [`FileChooserDialog`][crate::FileChooserDialog] associated with the button.
1508 pub fn title(self, title: impl Into<glib::GString>) -> Self {
1509 Self {
1510 builder: self.builder.property("title", title.into()),
1511 }
1512 }
1513
1514 /// The width of the entry and label inside the button, in characters.
1515 pub fn width_chars(self, width_chars: i32) -> Self {
1516 Self {
1517 builder: self.builder.property("width-chars", width_chars),
1518 }
1519 }
1520
1521 pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
1522 Self {
1523 builder: self
1524 .builder
1525 .property("baseline-position", baseline_position),
1526 }
1527 }
1528
1529 pub fn homogeneous(self, homogeneous: bool) -> Self {
1530 Self {
1531 builder: self.builder.property("homogeneous", homogeneous),
1532 }
1533 }
1534
1535 pub fn spacing(self, spacing: i32) -> Self {
1536 Self {
1537 builder: self.builder.property("spacing", spacing),
1538 }
1539 }
1540
1541 pub fn border_width(self, border_width: u32) -> Self {
1542 Self {
1543 builder: self.builder.property("border-width", border_width),
1544 }
1545 }
1546
1547 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1548 Self {
1549 builder: self.builder.property("child", child.clone().upcast()),
1550 }
1551 }
1552
1553 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1554 Self {
1555 builder: self.builder.property("resize-mode", resize_mode),
1556 }
1557 }
1558
1559 pub fn app_paintable(self, app_paintable: bool) -> Self {
1560 Self {
1561 builder: self.builder.property("app-paintable", app_paintable),
1562 }
1563 }
1564
1565 pub fn can_default(self, can_default: bool) -> Self {
1566 Self {
1567 builder: self.builder.property("can-default", can_default),
1568 }
1569 }
1570
1571 pub fn can_focus(self, can_focus: bool) -> Self {
1572 Self {
1573 builder: self.builder.property("can-focus", can_focus),
1574 }
1575 }
1576
1577 pub fn events(self, events: gdk::EventMask) -> Self {
1578 Self {
1579 builder: self.builder.property("events", events),
1580 }
1581 }
1582
1583 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1584 pub fn expand(self, expand: bool) -> Self {
1585 Self {
1586 builder: self.builder.property("expand", expand),
1587 }
1588 }
1589
1590 /// Whether the widget should grab focus when it is clicked with the mouse.
1591 ///
1592 /// This property is only relevant for widgets that can take focus.
1593 ///
1594 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1595 /// GtkComboBox) implemented this property individually.
1596 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1597 Self {
1598 builder: self.builder.property("focus-on-click", focus_on_click),
1599 }
1600 }
1601
1602 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1603 pub fn halign(self, halign: Align) -> Self {
1604 Self {
1605 builder: self.builder.property("halign", halign),
1606 }
1607 }
1608
1609 pub fn has_default(self, has_default: bool) -> Self {
1610 Self {
1611 builder: self.builder.property("has-default", has_default),
1612 }
1613 }
1614
1615 pub fn has_focus(self, has_focus: bool) -> Self {
1616 Self {
1617 builder: self.builder.property("has-focus", has_focus),
1618 }
1619 }
1620
1621 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1622 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1623 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1624 /// whether it will provide a tooltip or not.
1625 ///
1626 /// Note that setting this property to [`true`] for the first time will change
1627 /// the event masks of the GdkWindows of this widget to include leave-notify
1628 /// and motion-notify events. This cannot and will not be undone when the
1629 /// property is set to [`false`] again.
1630 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1631 Self {
1632 builder: self.builder.property("has-tooltip", has_tooltip),
1633 }
1634 }
1635
1636 pub fn height_request(self, height_request: i32) -> Self {
1637 Self {
1638 builder: self.builder.property("height-request", height_request),
1639 }
1640 }
1641
1642 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1643 pub fn hexpand(self, hexpand: bool) -> Self {
1644 Self {
1645 builder: self.builder.property("hexpand", hexpand),
1646 }
1647 }
1648
1649 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1650 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1651 Self {
1652 builder: self.builder.property("hexpand-set", hexpand_set),
1653 }
1654 }
1655
1656 pub fn is_focus(self, is_focus: bool) -> Self {
1657 Self {
1658 builder: self.builder.property("is-focus", is_focus),
1659 }
1660 }
1661
1662 /// Sets all four sides' margin at once. If read, returns max
1663 /// margin on any side.
1664 pub fn margin(self, margin: i32) -> Self {
1665 Self {
1666 builder: self.builder.property("margin", margin),
1667 }
1668 }
1669
1670 /// Margin on bottom side of widget.
1671 ///
1672 /// This property adds margin outside of the widget's normal size
1673 /// request, the margin will be added in addition to the size from
1674 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1675 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1676 Self {
1677 builder: self.builder.property("margin-bottom", margin_bottom),
1678 }
1679 }
1680
1681 /// Margin on end of widget, horizontally. This property supports
1682 /// left-to-right and right-to-left text directions.
1683 ///
1684 /// This property adds margin outside of the widget's normal size
1685 /// request, the margin will be added in addition to the size from
1686 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1687 pub fn margin_end(self, margin_end: i32) -> Self {
1688 Self {
1689 builder: self.builder.property("margin-end", margin_end),
1690 }
1691 }
1692
1693 /// Margin on start of widget, horizontally. This property supports
1694 /// left-to-right and right-to-left text directions.
1695 ///
1696 /// This property adds margin outside of the widget's normal size
1697 /// request, the margin will be added in addition to the size from
1698 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1699 pub fn margin_start(self, margin_start: i32) -> Self {
1700 Self {
1701 builder: self.builder.property("margin-start", margin_start),
1702 }
1703 }
1704
1705 /// Margin on top side of widget.
1706 ///
1707 /// This property adds margin outside of the widget's normal size
1708 /// request, the margin will be added in addition to the size from
1709 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1710 pub fn margin_top(self, margin_top: i32) -> Self {
1711 Self {
1712 builder: self.builder.property("margin-top", margin_top),
1713 }
1714 }
1715
1716 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1717 Self {
1718 builder: self.builder.property("name", name.into()),
1719 }
1720 }
1721
1722 pub fn no_show_all(self, no_show_all: bool) -> Self {
1723 Self {
1724 builder: self.builder.property("no-show-all", no_show_all),
1725 }
1726 }
1727
1728 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1729 /// more details about window opacity.
1730 ///
1731 /// Before 3.8 this was only available in GtkWindow
1732 pub fn opacity(self, opacity: f64) -> Self {
1733 Self {
1734 builder: self.builder.property("opacity", opacity),
1735 }
1736 }
1737
1738 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1739 Self {
1740 builder: self.builder.property("parent", parent.clone().upcast()),
1741 }
1742 }
1743
1744 pub fn receives_default(self, receives_default: bool) -> Self {
1745 Self {
1746 builder: self.builder.property("receives-default", receives_default),
1747 }
1748 }
1749
1750 pub fn sensitive(self, sensitive: bool) -> Self {
1751 Self {
1752 builder: self.builder.property("sensitive", sensitive),
1753 }
1754 }
1755
1756 /// Sets the text of tooltip to be the given string, which is marked up
1757 /// with the [Pango text markup language][PangoMarkupFormat].
1758 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1759 ///
1760 /// This is a convenience property which will take care of getting the
1761 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1762 /// will automatically be set to [`true`] and there will be taken care of
1763 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1764 ///
1765 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1766 /// are set, the last one wins.
1767 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1768 Self {
1769 builder: self
1770 .builder
1771 .property("tooltip-markup", tooltip_markup.into()),
1772 }
1773 }
1774
1775 /// Sets the text of tooltip to be the given string.
1776 ///
1777 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1778 ///
1779 /// This is a convenience property which will take care of getting the
1780 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1781 /// will automatically be set to [`true`] and there will be taken care of
1782 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1783 ///
1784 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1785 /// are set, the last one wins.
1786 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1787 Self {
1788 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1789 }
1790 }
1791
1792 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1793 pub fn valign(self, valign: Align) -> Self {
1794 Self {
1795 builder: self.builder.property("valign", valign),
1796 }
1797 }
1798
1799 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1800 pub fn vexpand(self, vexpand: bool) -> Self {
1801 Self {
1802 builder: self.builder.property("vexpand", vexpand),
1803 }
1804 }
1805
1806 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1807 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1808 Self {
1809 builder: self.builder.property("vexpand-set", vexpand_set),
1810 }
1811 }
1812
1813 pub fn visible(self, visible: bool) -> Self {
1814 Self {
1815 builder: self.builder.property("visible", visible),
1816 }
1817 }
1818
1819 pub fn width_request(self, width_request: i32) -> Self {
1820 Self {
1821 builder: self.builder.property("width-request", width_request),
1822 }
1823 }
1824
1825 /// The orientation of the orientable.
1826 pub fn orientation(self, orientation: Orientation) -> Self {
1827 Self {
1828 builder: self.builder.property("orientation", orientation),
1829 }
1830 }
1831
1832 pub fn action(self, action: FileChooserAction) -> Self {
1833 Self {
1834 builder: self.builder.property("action", action),
1835 }
1836 }
1837
1838 /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
1839 /// will offer the user to create new folders.
1840 pub fn create_folders(self, create_folders: bool) -> Self {
1841 Self {
1842 builder: self.builder.property("create-folders", create_folders),
1843 }
1844 }
1845
1846 /// Whether a file chooser in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode
1847 /// will present an overwrite confirmation dialog if the user
1848 /// selects a file name that already exists.
1849 pub fn do_overwrite_confirmation(self, do_overwrite_confirmation: bool) -> Self {
1850 Self {
1851 builder: self
1852 .builder
1853 .property("do-overwrite-confirmation", do_overwrite_confirmation),
1854 }
1855 }
1856
1857 pub fn extra_widget(self, extra_widget: &impl IsA<Widget>) -> Self {
1858 Self {
1859 builder: self
1860 .builder
1861 .property("extra-widget", extra_widget.clone().upcast()),
1862 }
1863 }
1864
1865 pub fn filter(self, filter: &FileFilter) -> Self {
1866 Self {
1867 builder: self.builder.property("filter", filter.clone()),
1868 }
1869 }
1870
1871 pub fn local_only(self, local_only: bool) -> Self {
1872 Self {
1873 builder: self.builder.property("local-only", local_only),
1874 }
1875 }
1876
1877 pub fn preview_widget(self, preview_widget: &impl IsA<Widget>) -> Self {
1878 Self {
1879 builder: self
1880 .builder
1881 .property("preview-widget", preview_widget.clone().upcast()),
1882 }
1883 }
1884
1885 pub fn preview_widget_active(self, preview_widget_active: bool) -> Self {
1886 Self {
1887 builder: self
1888 .builder
1889 .property("preview-widget-active", preview_widget_active),
1890 }
1891 }
1892
1893 pub fn select_multiple(self, select_multiple: bool) -> Self {
1894 Self {
1895 builder: self.builder.property("select-multiple", select_multiple),
1896 }
1897 }
1898
1899 pub fn show_hidden(self, show_hidden: bool) -> Self {
1900 Self {
1901 builder: self.builder.property("show-hidden", show_hidden),
1902 }
1903 }
1904
1905 pub fn use_preview_label(self, use_preview_label: bool) -> Self {
1906 Self {
1907 builder: self
1908 .builder
1909 .property("use-preview-label", use_preview_label),
1910 }
1911 }
1912
1913 // rustdoc-stripper-ignore-next
1914 /// Build the [`FileChooserButton`].
1915 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1916 pub fn build(self) -> FileChooserButton {
1917 self.builder.build()
1918 }
1919}
1920
1921mod sealed {
1922 pub trait Sealed {}
1923 impl<T: super::IsA<super::FileChooserButton>> Sealed for T {}
1924}
1925
1926/// Trait containing all [`struct@FileChooserButton`] methods.
1927///
1928/// # Implementors
1929///
1930/// [`FileChooserButton`][struct@crate::FileChooserButton]
1931pub trait FileChooserButtonExt: IsA<FileChooserButton> + sealed::Sealed + 'static {
1932 /// Retrieves the title of the browse dialog used by `self`. The returned value
1933 /// should not be modified or freed.
1934 ///
1935 /// # Returns
1936 ///
1937 /// a pointer to the browse dialog’s title.
1938 #[doc(alias = "gtk_file_chooser_button_get_title")]
1939 #[doc(alias = "get_title")]
1940 fn title(&self) -> Option<glib::GString> {
1941 unsafe {
1942 from_glib_none(ffi::gtk_file_chooser_button_get_title(
1943 self.as_ref().to_glib_none().0,
1944 ))
1945 }
1946 }
1947
1948 /// Retrieves the width in characters of the `self` widget’s entry and/or label.
1949 ///
1950 /// # Returns
1951 ///
1952 /// an integer width (in characters) that the button will use to size itself.
1953 #[doc(alias = "gtk_file_chooser_button_get_width_chars")]
1954 #[doc(alias = "get_width_chars")]
1955 fn width_chars(&self) -> i32 {
1956 unsafe { ffi::gtk_file_chooser_button_get_width_chars(self.as_ref().to_glib_none().0) }
1957 }
1958
1959 /// Modifies the `title` of the browse dialog used by `self`.
1960 /// ## `title`
1961 /// the new browse dialog title.
1962 #[doc(alias = "gtk_file_chooser_button_set_title")]
1963 fn set_title(&self, title: &str) {
1964 unsafe {
1965 ffi::gtk_file_chooser_button_set_title(
1966 self.as_ref().to_glib_none().0,
1967 title.to_glib_none().0,
1968 );
1969 }
1970 }
1971
1972 /// Sets the width (in characters) that `self` will use to `n_chars`.
1973 /// ## `n_chars`
1974 /// the new width, in characters.
1975 #[doc(alias = "gtk_file_chooser_button_set_width_chars")]
1976 fn set_width_chars(&self, n_chars: i32) {
1977 unsafe {
1978 ffi::gtk_file_chooser_button_set_width_chars(self.as_ref().to_glib_none().0, n_chars);
1979 }
1980 }
1981
1982 /// The ::file-set signal is emitted when the user selects a file.
1983 ///
1984 /// Note that this signal is only emitted when the user
1985 /// changes the file.
1986 #[doc(alias = "file-set")]
1987 fn connect_file_set<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1988 unsafe extern "C" fn file_set_trampoline<P: IsA<FileChooserButton>, F: Fn(&P) + 'static>(
1989 this: *mut ffi::GtkFileChooserButton,
1990 f: glib::ffi::gpointer,
1991 ) {
1992 let f: &F = &*(f as *const F);
1993 f(FileChooserButton::from_glib_borrow(this).unsafe_cast_ref())
1994 }
1995 unsafe {
1996 let f: Box_<F> = Box_::new(f);
1997 connect_raw(
1998 self.as_ptr() as *mut _,
1999 b"file-set\0".as_ptr() as *const _,
2000 Some(transmute::<_, unsafe extern "C" fn()>(
2001 file_set_trampoline::<Self, F> as *const (),
2002 )),
2003 Box_::into_raw(f),
2004 )
2005 }
2006 }
2007
2008 #[doc(alias = "title")]
2009 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2010 unsafe extern "C" fn notify_title_trampoline<
2011 P: IsA<FileChooserButton>,
2012 F: Fn(&P) + 'static,
2013 >(
2014 this: *mut ffi::GtkFileChooserButton,
2015 _param_spec: glib::ffi::gpointer,
2016 f: glib::ffi::gpointer,
2017 ) {
2018 let f: &F = &*(f as *const F);
2019 f(FileChooserButton::from_glib_borrow(this).unsafe_cast_ref())
2020 }
2021 unsafe {
2022 let f: Box_<F> = Box_::new(f);
2023 connect_raw(
2024 self.as_ptr() as *mut _,
2025 b"notify::title\0".as_ptr() as *const _,
2026 Some(transmute::<_, unsafe extern "C" fn()>(
2027 notify_title_trampoline::<Self, F> as *const (),
2028 )),
2029 Box_::into_raw(f),
2030 )
2031 }
2032 }
2033
2034 #[doc(alias = "width-chars")]
2035 fn connect_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2036 unsafe extern "C" fn notify_width_chars_trampoline<
2037 P: IsA<FileChooserButton>,
2038 F: Fn(&P) + 'static,
2039 >(
2040 this: *mut ffi::GtkFileChooserButton,
2041 _param_spec: glib::ffi::gpointer,
2042 f: glib::ffi::gpointer,
2043 ) {
2044 let f: &F = &*(f as *const F);
2045 f(FileChooserButton::from_glib_borrow(this).unsafe_cast_ref())
2046 }
2047 unsafe {
2048 let f: Box_<F> = Box_::new(f);
2049 connect_raw(
2050 self.as_ptr() as *mut _,
2051 b"notify::width-chars\0".as_ptr() as *const _,
2052 Some(transmute::<_, unsafe extern "C" fn()>(
2053 notify_width_chars_trampoline::<Self, F> as *const (),
2054 )),
2055 Box_::into_raw(f),
2056 )
2057 }
2058 }
2059}
2060
2061impl<O: IsA<FileChooserButton>> FileChooserButtonExt for O {}
2062
2063impl fmt::Display for FileChooserButton {
2064 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2065 f.write_str("FileChooserButton")
2066 }
2067}