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