gtk/auto/combo_box.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, Bin, Buildable, CellArea, CellEditable, CellLayout, Container, ResizeMode, ScrollType,
7 SensitivityType, TreeIter, TreeModel, 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 /// A GtkComboBox is a widget that allows the user to choose from a list of
19 /// valid choices. The GtkComboBox displays the selected choice. When
20 /// activated, the GtkComboBox displays a popup which allows the user to
21 /// make a new choice. The style in which the selected value is displayed,
22 /// and the style of the popup is determined by the current theme. It may
23 /// be similar to a Windows-style combo box.
24 ///
25 /// The GtkComboBox uses the model-view pattern; the list of valid choices
26 /// is specified in the form of a tree model, and the display of the choices
27 /// can be adapted to the data in the model by using cell renderers, as you
28 /// would in a tree view. This is possible since GtkComboBox implements the
29 /// [`CellLayout`][crate::CellLayout] interface. The tree model holding the valid choices is
30 /// not restricted to a flat list, it can be a real tree, and the popup will
31 /// reflect the tree structure.
32 ///
33 /// To allow the user to enter values not in the model, the “has-entry”
34 /// property allows the GtkComboBox to contain a [`Entry`][crate::Entry]. This entry
35 /// can be accessed by calling [`BinExt::child()`][crate::prelude::BinExt::child()] on the combo box.
36 ///
37 /// For a simple list of textual choices, the model-view API of GtkComboBox
38 /// can be a bit overwhelming. In this case, [`ComboBoxText`][crate::ComboBoxText] offers a
39 /// simple alternative. Both GtkComboBox and [`ComboBoxText`][crate::ComboBoxText] can contain
40 /// an entry.
41 ///
42 /// # CSS nodes
43 ///
44 ///
45 ///
46 /// **⚠️ The following code is in plain ⚠️**
47 ///
48 /// ```plain
49 /// combobox
50 /// ├── box.linked
51 /// │ ╰── button.combo
52 /// │ ╰── box
53 /// │ ├── cellview
54 /// │ ╰── arrow
55 /// ╰── window.popup
56 /// ```
57 ///
58 /// A normal combobox contains a box with the .linked class, a button
59 /// with the .combo class and inside those buttons, there are a cellview and
60 /// an arrow.
61 ///
62 ///
63 ///
64 /// **⚠️ The following code is in plain ⚠️**
65 ///
66 /// ```plain
67 /// combobox
68 /// ├── box.linked
69 /// │ ├── entry.combo
70 /// │ ╰── button.combo
71 /// │ ╰── box
72 /// │ ╰── arrow
73 /// ╰── window.popup
74 /// ```
75 ///
76 /// A GtkComboBox with an entry has a single CSS node with name combobox. It
77 /// contains a box with the .linked class. That box contains an entry and a
78 /// button, both with the .combo class added.
79 /// The button also contains another node with name arrow.
80 ///
81 /// ## Properties
82 ///
83 ///
84 /// #### `active`
85 /// The item which is currently active. If the model is a non-flat treemodel,
86 /// and the active item is not an immediate child of the root of the tree,
87 /// this property has the value
88 /// `gtk_tree_path_get_indices (path)[0]`,
89 /// where `path` is the [`TreePath`][crate::TreePath] of the active item.
90 ///
91 /// Readable | Writable
92 ///
93 ///
94 /// #### `active-id`
95 /// The value of the ID column of the active row.
96 ///
97 /// Readable | Writable
98 ///
99 ///
100 /// #### `add-tearoffs`
101 /// The add-tearoffs property controls whether generated menus
102 /// have tearoff menu items.
103 ///
104 /// Note that this only affects menu style combo boxes.
105 ///
106 /// Readable | Writable
107 ///
108 ///
109 /// #### `button-sensitivity`
110 /// Whether the dropdown button is sensitive when
111 /// the model is empty.
112 ///
113 /// Readable | Writable
114 ///
115 ///
116 /// #### `cell-area`
117 /// The [`CellArea`][crate::CellArea] used to layout cell renderers for this combo box.
118 ///
119 /// If no area is specified when creating the combo box with [`ComboBox::with_area()`][crate::ComboBox::with_area()]
120 /// a horizontally oriented [`CellAreaBox`][crate::CellAreaBox] will be used.
121 ///
122 /// Readable | Writable | Construct Only
123 ///
124 ///
125 /// #### `column-span-column`
126 /// If this is set to a non-negative value, it must be the index of a column
127 /// of type `G_TYPE_INT` in the model. The value in that column for each item
128 /// will determine how many columns that item will span in the popup.
129 /// Therefore, values in this column must be greater than zero, and the sum of
130 /// an item’s column position + span should not exceed [`wrap-width`][struct@crate::ComboBox#wrap-width].
131 ///
132 /// Readable | Writable
133 ///
134 ///
135 /// #### `entry-text-column`
136 /// The column in the combo box's model to associate with strings from the entry
137 /// if the combo was created with [`has-entry`][struct@crate::ComboBox#has-entry] = [`true`].
138 ///
139 /// Readable | Writable
140 ///
141 ///
142 /// #### `has-entry`
143 /// Whether the combo box has an entry.
144 ///
145 /// Readable | Writable | Construct Only
146 ///
147 ///
148 /// #### `has-frame`
149 /// The has-frame property controls whether a frame
150 /// is drawn around the entry.
151 ///
152 /// Readable | Writable
153 ///
154 ///
155 /// #### `id-column`
156 /// The column in the combo box's model that provides string
157 /// IDs for the values in the model, if != -1.
158 ///
159 /// Readable | Writable
160 ///
161 ///
162 /// #### `model`
163 /// The model from which the combo box takes the values shown
164 /// in the list.
165 ///
166 /// Readable | Writable
167 ///
168 ///
169 /// #### `popup-fixed-width`
170 /// Whether the popup's width should be a fixed width matching the
171 /// allocated width of the combo box.
172 ///
173 /// Readable | Writable
174 ///
175 ///
176 /// #### `popup-shown`
177 /// Whether the combo boxes dropdown is popped up.
178 /// Note that this property is mainly useful, because
179 /// it allows you to connect to notify::popup-shown.
180 ///
181 /// Readable
182 ///
183 ///
184 /// #### `row-span-column`
185 /// If this is set to a non-negative value, it must be the index of a column
186 /// of type `G_TYPE_INT` in the model. The value in that column for each item
187 /// will determine how many rows that item will span in the popup. Therefore,
188 /// values in this column must be greater than zero.
189 ///
190 /// Readable | Writable
191 ///
192 ///
193 /// #### `tearoff-title`
194 /// A title that may be displayed by the window manager
195 /// when the popup is torn-off.
196 ///
197 /// Readable | Writable
198 ///
199 ///
200 /// #### `wrap-width`
201 /// If wrap-width is set to a positive value, items in the popup will be laid
202 /// out along multiple columns, starting a new row on reaching the wrap width.
203 ///
204 /// Readable | Writable
205 /// <details><summary><h4>Container</h4></summary>
206 ///
207 ///
208 /// #### `border-width`
209 /// Readable | Writable
210 ///
211 ///
212 /// #### `child`
213 /// Writable
214 ///
215 ///
216 /// #### `resize-mode`
217 /// Readable | Writable
218 /// </details>
219 /// <details><summary><h4>Widget</h4></summary>
220 ///
221 ///
222 /// #### `app-paintable`
223 /// Readable | Writable
224 ///
225 ///
226 /// #### `can-default`
227 /// Readable | Writable
228 ///
229 ///
230 /// #### `can-focus`
231 /// Readable | Writable
232 ///
233 ///
234 /// #### `composite-child`
235 /// Readable
236 ///
237 ///
238 /// #### `double-buffered`
239 /// Whether the widget is double buffered.
240 ///
241 /// Readable | Writable
242 ///
243 ///
244 /// #### `events`
245 /// Readable | Writable
246 ///
247 ///
248 /// #### `expand`
249 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
250 ///
251 /// Readable | Writable
252 ///
253 ///
254 /// #### `focus-on-click`
255 /// Whether the widget should grab focus when it is clicked with the mouse.
256 ///
257 /// This property is only relevant for widgets that can take focus.
258 ///
259 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
260 /// GtkComboBox) implemented this property individually.
261 ///
262 /// Readable | Writable
263 ///
264 ///
265 /// #### `halign`
266 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
267 ///
268 /// Readable | Writable
269 ///
270 ///
271 /// #### `has-default`
272 /// Readable | Writable
273 ///
274 ///
275 /// #### `has-focus`
276 /// Readable | Writable
277 ///
278 ///
279 /// #### `has-tooltip`
280 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
281 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
282 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
283 /// whether it will provide a tooltip or not.
284 ///
285 /// Note that setting this property to [`true`] for the first time will change
286 /// the event masks of the GdkWindows of this widget to include leave-notify
287 /// and motion-notify events. This cannot and will not be undone when the
288 /// property is set to [`false`] again.
289 ///
290 /// Readable | Writable
291 ///
292 ///
293 /// #### `height-request`
294 /// Readable | Writable
295 ///
296 ///
297 /// #### `hexpand`
298 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
299 ///
300 /// Readable | Writable
301 ///
302 ///
303 /// #### `hexpand-set`
304 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
305 ///
306 /// Readable | Writable
307 ///
308 ///
309 /// #### `is-focus`
310 /// Readable | Writable
311 ///
312 ///
313 /// #### `margin`
314 /// Sets all four sides' margin at once. If read, returns max
315 /// margin on any side.
316 ///
317 /// Readable | Writable
318 ///
319 ///
320 /// #### `margin-bottom`
321 /// Margin on bottom side of widget.
322 ///
323 /// This property adds margin outside of the widget's normal size
324 /// request, the margin will be added in addition to the size from
325 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
326 ///
327 /// Readable | Writable
328 ///
329 ///
330 /// #### `margin-end`
331 /// Margin on end of widget, horizontally. This property supports
332 /// left-to-right and right-to-left text directions.
333 ///
334 /// This property adds margin outside of the widget's normal size
335 /// request, the margin will be added in addition to the size from
336 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
337 ///
338 /// Readable | Writable
339 ///
340 ///
341 /// #### `margin-left`
342 /// Margin on left side of widget.
343 ///
344 /// This property adds margin outside of the widget's normal size
345 /// request, the margin will be added in addition to the size from
346 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
347 ///
348 /// Readable | Writable
349 ///
350 ///
351 /// #### `margin-right`
352 /// Margin on right side of widget.
353 ///
354 /// This property adds margin outside of the widget's normal size
355 /// request, the margin will be added in addition to the size from
356 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
357 ///
358 /// Readable | Writable
359 ///
360 ///
361 /// #### `margin-start`
362 /// Margin on start of widget, horizontally. This property supports
363 /// left-to-right and right-to-left text directions.
364 ///
365 /// This property adds margin outside of the widget's normal size
366 /// request, the margin will be added in addition to the size from
367 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
368 ///
369 /// Readable | Writable
370 ///
371 ///
372 /// #### `margin-top`
373 /// Margin on top side of widget.
374 ///
375 /// This property adds margin outside of the widget's normal size
376 /// request, the margin will be added in addition to the size from
377 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
378 ///
379 /// Readable | Writable
380 ///
381 ///
382 /// #### `name`
383 /// Readable | Writable
384 ///
385 ///
386 /// #### `no-show-all`
387 /// Readable | Writable
388 ///
389 ///
390 /// #### `opacity`
391 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
392 /// more details about window opacity.
393 ///
394 /// Before 3.8 this was only available in GtkWindow
395 ///
396 /// Readable | Writable
397 ///
398 ///
399 /// #### `parent`
400 /// Readable | Writable
401 ///
402 ///
403 /// #### `receives-default`
404 /// Readable | Writable
405 ///
406 ///
407 /// #### `scale-factor`
408 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
409 /// more details about widget scaling.
410 ///
411 /// Readable
412 ///
413 ///
414 /// #### `sensitive`
415 /// Readable | Writable
416 ///
417 ///
418 /// #### `style`
419 /// The style of the widget, which contains information about how it will look (colors, etc).
420 ///
421 /// Readable | Writable
422 ///
423 ///
424 /// #### `tooltip-markup`
425 /// Sets the text of tooltip to be the given string, which is marked up
426 /// with the [Pango text markup language][PangoMarkupFormat].
427 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
428 ///
429 /// This is a convenience property which will take care of getting the
430 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
431 /// will automatically be set to [`true`] and there will be taken care of
432 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
433 ///
434 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
435 /// are set, the last one wins.
436 ///
437 /// Readable | Writable
438 ///
439 ///
440 /// #### `tooltip-text`
441 /// Sets the text of tooltip to be the given string.
442 ///
443 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
444 ///
445 /// This is a convenience property which will take care of getting the
446 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
447 /// will automatically be set to [`true`] and there will be taken care of
448 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
449 ///
450 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
451 /// are set, the last one wins.
452 ///
453 /// Readable | Writable
454 ///
455 ///
456 /// #### `valign`
457 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
458 ///
459 /// Readable | Writable
460 ///
461 ///
462 /// #### `vexpand`
463 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
464 ///
465 /// Readable | Writable
466 ///
467 ///
468 /// #### `vexpand-set`
469 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
470 ///
471 /// Readable | Writable
472 ///
473 ///
474 /// #### `visible`
475 /// Readable | Writable
476 ///
477 ///
478 /// #### `width-request`
479 /// Readable | Writable
480 ///
481 ///
482 /// #### `window`
483 /// The widget's window if it is realized, [`None`] otherwise.
484 ///
485 /// Readable
486 /// </details>
487 /// <details><summary><h4>CellEditable</h4></summary>
488 ///
489 ///
490 /// #### `editing-canceled`
491 /// Indicates whether editing on the cell has been canceled.
492 ///
493 /// Readable | Writable
494 /// </details>
495 ///
496 /// ## Signals
497 ///
498 ///
499 /// #### `changed`
500 /// The changed signal is emitted when the active
501 /// item is changed. The can be due to the user selecting
502 /// a different item from the list, or due to a
503 /// call to [`ComboBoxExt::set_active_iter()`][crate::prelude::ComboBoxExt::set_active_iter()].
504 /// It will also be emitted while typing into the entry of a combo box
505 /// with an entry.
506 ///
507 ///
508 ///
509 ///
510 /// #### `format-entry-text`
511 /// For combo boxes that are created with an entry (See GtkComboBox:has-entry).
512 ///
513 /// A signal which allows you to change how the text displayed in a combo box's
514 /// entry is displayed.
515 ///
516 /// Connect a signal handler which returns an allocated string representing
517 /// `path`. That string will then be used to set the text in the combo box's entry.
518 /// The default signal handler uses the text from the GtkComboBox::entry-text-column
519 /// model column.
520 ///
521 /// Here's an example signal handler which fetches data from the model and
522 /// displays it in the entry.
523 ///
524 ///
525 /// **⚠️ The following code is in C ⚠️**
526 ///
527 /// ```C
528 /// static gchar*
529 /// format_entry_text_callback (GtkComboBox *combo,
530 /// const gchar *path,
531 /// gpointer user_data)
532 /// {
533 /// GtkTreeIter iter;
534 /// GtkTreeModel model;
535 /// gdouble value;
536 ///
537 /// model = gtk_combo_box_get_model (combo);
538 ///
539 /// gtk_tree_model_get_iter_from_string (model, &iter, path);
540 /// gtk_tree_model_get (model, &iter,
541 /// THE_DOUBLE_VALUE_COLUMN, &value,
542 /// -1);
543 ///
544 /// return g_strdup_printf ("%g", value);
545 /// }
546 /// ```
547 ///
548 ///
549 ///
550 ///
551 /// #### `move-active`
552 /// The ::move-active signal is a
553 /// [keybinding signal][GtkBindingSignal]
554 /// which gets emitted to move the active selection.
555 ///
556 /// Action
557 ///
558 ///
559 /// #### `popdown`
560 /// The ::popdown signal is a
561 /// [keybinding signal][GtkBindingSignal]
562 /// which gets emitted to popdown the combo box list.
563 ///
564 /// The default bindings for this signal are Alt+Up and Escape.
565 ///
566 /// Action
567 ///
568 ///
569 /// #### `popup`
570 /// The ::popup signal is a
571 /// [keybinding signal][GtkBindingSignal]
572 /// which gets emitted to popup the combo box list.
573 ///
574 /// The default binding for this signal is Alt+Down.
575 ///
576 /// Action
577 /// <details><summary><h4>Container</h4></summary>
578 ///
579 ///
580 /// #### `add`
581 ///
582 ///
583 ///
584 /// #### `check-resize`
585 ///
586 ///
587 ///
588 /// #### `remove`
589 ///
590 ///
591 ///
592 /// #### `set-focus-child`
593 ///
594 /// </details>
595 /// <details><summary><h4>Widget</h4></summary>
596 ///
597 ///
598 /// #### `accel-closures-changed`
599 ///
600 ///
601 ///
602 /// #### `button-press-event`
603 /// The ::button-press-event signal will be emitted when a button
604 /// (typically from a mouse) is pressed.
605 ///
606 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
607 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
608 ///
609 /// This signal will be sent to the grab widget if there is one.
610 ///
611 ///
612 ///
613 ///
614 /// #### `button-release-event`
615 /// The ::button-release-event signal will be emitted when a button
616 /// (typically from a mouse) is released.
617 ///
618 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
619 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
620 ///
621 /// This signal will be sent to the grab widget if there is one.
622 ///
623 ///
624 ///
625 ///
626 /// #### `can-activate-accel`
627 /// Determines whether an accelerator that activates the signal
628 /// identified by `signal_id` can currently be activated.
629 /// This signal is present to allow applications and derived
630 /// widgets to override the default [`Widget`][crate::Widget] handling
631 /// for determining whether an accelerator can be activated.
632 ///
633 ///
634 ///
635 ///
636 /// #### `child-notify`
637 /// The ::child-notify signal is emitted for each
638 /// [child property][child-properties] that has
639 /// changed on an object. The signal's detail holds the property name.
640 ///
641 /// Detailed
642 ///
643 ///
644 /// #### `composited-changed`
645 /// The ::composited-changed signal is emitted when the composited
646 /// status of `widgets` screen changes.
647 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
648 ///
649 /// Action
650 ///
651 ///
652 /// #### `configure-event`
653 /// The ::configure-event signal will be emitted when the size, position or
654 /// stacking of the `widget`'s window has changed.
655 ///
656 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
657 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
658 /// automatically for all new windows.
659 ///
660 ///
661 ///
662 ///
663 /// #### `damage-event`
664 /// Emitted when a redirected window belonging to `widget` gets drawn into.
665 /// The region/area members of the event shows what area of the redirected
666 /// drawable was drawn into.
667 ///
668 ///
669 ///
670 ///
671 /// #### `delete-event`
672 /// The ::delete-event signal is emitted if a user requests that
673 /// a toplevel window is closed. The default handler for this signal
674 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
675 /// this signal will cause the window to be hidden instead, so that
676 /// it can later be shown again without reconstructing it.
677 ///
678 ///
679 ///
680 ///
681 /// #### `destroy`
682 /// Signals that all holders of a reference to the widget should release
683 /// the reference that they hold. May result in finalization of the widget
684 /// if all references are released.
685 ///
686 /// This signal is not suitable for saving widget state.
687 ///
688 ///
689 ///
690 ///
691 /// #### `destroy-event`
692 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
693 /// You rarely get this signal, because most widgets disconnect themselves
694 /// from their window before they destroy it, so no widget owns the
695 /// window at destroy time.
696 ///
697 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
698 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
699 /// automatically for all new windows.
700 ///
701 ///
702 ///
703 ///
704 /// #### `direction-changed`
705 /// The ::direction-changed signal is emitted when the text direction
706 /// of a widget changes.
707 ///
708 ///
709 ///
710 ///
711 /// #### `drag-begin`
712 /// The ::drag-begin signal is emitted on the drag source when a drag is
713 /// started. A typical reason to connect to this signal is to set up a
714 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
715 ///
716 /// Note that some widgets set up a drag icon in the default handler of
717 /// this signal, so you may have to use `g_signal_connect_after()` to
718 /// override what the default handler did.
719 ///
720 ///
721 ///
722 ///
723 /// #### `drag-data-delete`
724 /// The ::drag-data-delete signal is emitted on the drag source when a drag
725 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
726 /// handler is responsible for deleting the data that has been dropped. What
727 /// "delete" means depends on the context of the drag operation.
728 ///
729 ///
730 ///
731 ///
732 /// #### `drag-data-get`
733 /// The ::drag-data-get signal is emitted on the drag source when the drop
734 /// site requests the data which is dragged. It is the responsibility of
735 /// the signal handler to fill `data` with the data in the format which
736 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
737 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
738 ///
739 ///
740 ///
741 ///
742 /// #### `drag-data-received`
743 /// The ::drag-data-received signal is emitted on the drop site when the
744 /// dragged data has been received. If the data was received in order to
745 /// determine whether the drop will be accepted, the handler is expected
746 /// to call `gdk_drag_status()` and not finish the drag.
747 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
748 /// (and this is the last target to be received), the handler for this
749 /// signal is expected to process the received data and then call
750 /// `gtk_drag_finish()`, setting the `success` parameter depending on
751 /// whether the data was processed successfully.
752 ///
753 /// Applications must create some means to determine why the signal was emitted
754 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
755 ///
756 /// The handler may inspect the selected action with
757 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
758 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
759 /// shown in the following example:
760 ///
761 ///
762 /// **⚠️ The following code is in C ⚠️**
763 ///
764 /// ```C
765 /// void
766 /// drag_data_received (GtkWidget *widget,
767 /// GdkDragContext *context,
768 /// gint x,
769 /// gint y,
770 /// GtkSelectionData *data,
771 /// guint info,
772 /// guint time)
773 /// {
774 /// if ((data->length >= 0) && (data->format == 8))
775 /// {
776 /// GdkDragAction action;
777 ///
778 /// // handle data here
779 ///
780 /// action = gdk_drag_context_get_selected_action (context);
781 /// if (action == GDK_ACTION_ASK)
782 /// {
783 /// GtkWidget *dialog;
784 /// gint response;
785 ///
786 /// dialog = gtk_message_dialog_new (NULL,
787 /// GTK_DIALOG_MODAL |
788 /// GTK_DIALOG_DESTROY_WITH_PARENT,
789 /// GTK_MESSAGE_INFO,
790 /// GTK_BUTTONS_YES_NO,
791 /// "Move the data ?\n");
792 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
793 /// gtk_widget_destroy (dialog);
794 ///
795 /// if (response == GTK_RESPONSE_YES)
796 /// action = GDK_ACTION_MOVE;
797 /// else
798 /// action = GDK_ACTION_COPY;
799 /// }
800 ///
801 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
802 /// }
803 /// else
804 /// gtk_drag_finish (context, FALSE, FALSE, time);
805 /// }
806 /// ```
807 ///
808 ///
809 ///
810 ///
811 /// #### `drag-drop`
812 /// The ::drag-drop signal is emitted on the drop site when the user drops
813 /// the data onto the widget. The signal handler must determine whether
814 /// the cursor position is in a drop zone or not. If it is not in a drop
815 /// zone, it returns [`false`] and no further processing is necessary.
816 /// Otherwise, the handler returns [`true`]. In this case, the handler must
817 /// ensure that `gtk_drag_finish()` is called to let the source know that
818 /// the drop is done. The call to `gtk_drag_finish()` can be done either
819 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
820 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
821 /// or more of the supported targets.
822 ///
823 ///
824 ///
825 ///
826 /// #### `drag-end`
827 /// The ::drag-end signal is emitted on the drag source when a drag is
828 /// finished. A typical reason to connect to this signal is to undo
829 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
830 ///
831 ///
832 ///
833 ///
834 /// #### `drag-failed`
835 /// The ::drag-failed signal is emitted on the drag source when a drag has
836 /// failed. The signal handler may hook custom code to handle a failed DnD
837 /// operation based on the type of error, it returns [`true`] is the failure has
838 /// been already handled (not showing the default "drag operation failed"
839 /// animation), otherwise it returns [`false`].
840 ///
841 ///
842 ///
843 ///
844 /// #### `drag-leave`
845 /// The ::drag-leave signal is emitted on the drop site when the cursor
846 /// leaves the widget. A typical reason to connect to this signal is to
847 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
848 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
849 ///
850 ///
851 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
852 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
853 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
854 ///
855 ///
856 ///
857 ///
858 /// #### `drag-motion`
859 /// The ::drag-motion signal is emitted on the drop site when the user
860 /// moves the cursor over the widget during a drag. The signal handler
861 /// must determine whether the cursor position is in a drop zone or not.
862 /// If it is not in a drop zone, it returns [`false`] and no further processing
863 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
864 /// handler is responsible for providing the necessary information for
865 /// displaying feedback to the user, by calling `gdk_drag_status()`.
866 ///
867 /// If the decision whether the drop will be accepted or rejected can't be
868 /// made based solely on the cursor position and the type of the data, the
869 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
870 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
871 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
872 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
873 /// when using the drag-motion signal that way.
874 ///
875 /// Also note that there is no drag-enter signal. The drag receiver has to
876 /// keep track of whether he has received any drag-motion signals since the
877 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
878 /// an "enter" signal. Upon an "enter", the handler will typically highlight
879 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
880 ///
881 ///
882 /// **⚠️ The following code is in C ⚠️**
883 ///
884 /// ```C
885 /// static void
886 /// drag_motion (GtkWidget *widget,
887 /// GdkDragContext *context,
888 /// gint x,
889 /// gint y,
890 /// guint time)
891 /// {
892 /// GdkAtom target;
893 ///
894 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
895 ///
896 /// if (!private_data->drag_highlight)
897 /// {
898 /// private_data->drag_highlight = 1;
899 /// gtk_drag_highlight (widget);
900 /// }
901 ///
902 /// target = gtk_drag_dest_find_target (widget, context, NULL);
903 /// if (target == GDK_NONE)
904 /// gdk_drag_status (context, 0, time);
905 /// else
906 /// {
907 /// private_data->pending_status
908 /// = gdk_drag_context_get_suggested_action (context);
909 /// gtk_drag_get_data (widget, context, target, time);
910 /// }
911 ///
912 /// return TRUE;
913 /// }
914 ///
915 /// static void
916 /// drag_data_received (GtkWidget *widget,
917 /// GdkDragContext *context,
918 /// gint x,
919 /// gint y,
920 /// GtkSelectionData *selection_data,
921 /// guint info,
922 /// guint time)
923 /// {
924 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
925 ///
926 /// if (private_data->suggested_action)
927 /// {
928 /// private_data->suggested_action = 0;
929 ///
930 /// // We are getting this data due to a request in drag_motion,
931 /// // rather than due to a request in drag_drop, so we are just
932 /// // supposed to call gdk_drag_status(), not actually paste in
933 /// // the data.
934 ///
935 /// str = gtk_selection_data_get_text (selection_data);
936 /// if (!data_is_acceptable (str))
937 /// gdk_drag_status (context, 0, time);
938 /// else
939 /// gdk_drag_status (context,
940 /// private_data->suggested_action,
941 /// time);
942 /// }
943 /// else
944 /// {
945 /// // accept the drop
946 /// }
947 /// }
948 /// ```
949 ///
950 ///
951 ///
952 ///
953 /// #### `draw`
954 /// This signal is emitted when a widget is supposed to render itself.
955 /// The `widget`'s top left corner must be painted at the origin of
956 /// the passed in context and be sized to the values returned by
957 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
958 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
959 ///
960 /// Signal handlers connected to this signal can modify the cairo
961 /// context passed as `cr` in any way they like and don't need to
962 /// restore it. The signal emission takes care of calling `cairo_save()`
963 /// before and `cairo_restore()` after invoking the handler.
964 ///
965 /// The signal handler will get a `cr` with a clip region already set to the
966 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
967 /// widgets that want to avoid redrawing themselves completely can get the full
968 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
969 /// get a finer-grained representation of the dirty region with
970 /// `cairo_copy_clip_rectangle_list()`.
971 ///
972 ///
973 ///
974 ///
975 /// #### `enter-notify-event`
976 /// The ::enter-notify-event will be emitted when the pointer enters
977 /// the `widget`'s window.
978 ///
979 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
980 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
981 ///
982 /// This signal will be sent to the grab widget if there is one.
983 ///
984 ///
985 ///
986 ///
987 /// #### `event`
988 /// The GTK+ main loop will emit three signals for each GDK event delivered
989 /// to a widget: one generic ::event signal, another, more specific,
990 /// signal that matches the type of event delivered (e.g.
991 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
992 /// [`event-after`][struct@crate::Widget#event-after] signal.
993 ///
994 ///
995 ///
996 ///
997 /// #### `event-after`
998 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
999 /// the second more specific signal, ::event-after will be emitted
1000 /// regardless of the previous two signals handlers return values.
1001 ///
1002 ///
1003 ///
1004 ///
1005 /// #### `focus`
1006 ///
1007 ///
1008 ///
1009 /// #### `focus-in-event`
1010 /// The ::focus-in-event signal will be emitted when the keyboard focus
1011 /// enters the `widget`'s window.
1012 ///
1013 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1014 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1015 ///
1016 ///
1017 ///
1018 ///
1019 /// #### `focus-out-event`
1020 /// The ::focus-out-event signal will be emitted when the keyboard focus
1021 /// leaves the `widget`'s window.
1022 ///
1023 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1024 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1025 ///
1026 ///
1027 ///
1028 ///
1029 /// #### `grab-broken-event`
1030 /// Emitted when a pointer or keyboard grab on a window belonging
1031 /// to `widget` gets broken.
1032 ///
1033 /// On X11, this happens when the grab window becomes unviewable
1034 /// (i.e. it or one of its ancestors is unmapped), or if the same
1035 /// application grabs the pointer or keyboard again.
1036 ///
1037 ///
1038 ///
1039 ///
1040 /// #### `grab-focus`
1041 /// Action
1042 ///
1043 ///
1044 /// #### `grab-notify`
1045 /// The ::grab-notify signal is emitted when a widget becomes
1046 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1047 /// another widget, or when it becomes unshadowed due to a grab
1048 /// being removed.
1049 ///
1050 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
1051 /// grab widget in the grab stack of its window group is not
1052 /// its ancestor.
1053 ///
1054 ///
1055 ///
1056 ///
1057 /// #### `hide`
1058 /// The ::hide signal is emitted when `widget` is hidden, for example with
1059 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
1060 ///
1061 ///
1062 ///
1063 ///
1064 /// #### `hierarchy-changed`
1065 /// The ::hierarchy-changed signal is emitted when the
1066 /// anchored state of a widget changes. A widget is
1067 /// “anchored” when its toplevel
1068 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
1069 /// a widget changes from un-anchored to anchored or vice-versa.
1070 ///
1071 ///
1072 ///
1073 ///
1074 /// #### `key-press-event`
1075 /// The ::key-press-event signal is emitted when a key is pressed. The signal
1076 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
1077 ///
1078 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1079 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
1080 ///
1081 /// This signal will be sent to the grab widget if there is one.
1082 ///
1083 ///
1084 ///
1085 ///
1086 /// #### `key-release-event`
1087 /// The ::key-release-event signal is emitted when a key is released.
1088 ///
1089 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1090 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
1091 ///
1092 /// This signal will be sent to the grab widget if there is one.
1093 ///
1094 ///
1095 ///
1096 ///
1097 /// #### `keynav-failed`
1098 /// Gets emitted if keyboard navigation fails.
1099 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
1100 ///
1101 ///
1102 ///
1103 ///
1104 /// #### `leave-notify-event`
1105 /// The ::leave-notify-event will be emitted when the pointer leaves
1106 /// the `widget`'s window.
1107 ///
1108 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1109 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1110 ///
1111 /// This signal will be sent to the grab widget if there is one.
1112 ///
1113 ///
1114 ///
1115 ///
1116 /// #### `map`
1117 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1118 /// when the widget is visible (which is controlled with
1119 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1120 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1121 /// be emitted.
1122 ///
1123 /// The ::map signal can be used to determine whether a widget will be drawn,
1124 /// for instance it can resume an animation that was stopped during the
1125 /// emission of [`unmap`][struct@crate::Widget#unmap].
1126 ///
1127 ///
1128 ///
1129 ///
1130 /// #### `map-event`
1131 /// The ::map-event signal will be emitted when the `widget`'s window is
1132 /// mapped. A window is mapped when it becomes visible on the screen.
1133 ///
1134 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1135 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1136 /// automatically for all new windows.
1137 ///
1138 ///
1139 ///
1140 ///
1141 /// #### `mnemonic-activate`
1142 /// The default handler for this signal activates `widget` if `group_cycling`
1143 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1144 ///
1145 ///
1146 ///
1147 ///
1148 /// #### `motion-notify-event`
1149 /// The ::motion-notify-event signal is emitted when the pointer moves
1150 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1151 ///
1152 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1153 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1154 ///
1155 /// This signal will be sent to the grab widget if there is one.
1156 ///
1157 ///
1158 ///
1159 ///
1160 /// #### `move-focus`
1161 /// Action
1162 ///
1163 ///
1164 /// #### `parent-set`
1165 /// The ::parent-set signal is emitted when a new parent
1166 /// has been set on a widget.
1167 ///
1168 ///
1169 ///
1170 ///
1171 /// #### `popup-menu`
1172 /// This signal gets emitted whenever a widget should pop up a context
1173 /// menu. This usually happens through the standard key binding mechanism;
1174 /// by pressing a certain key while a widget is focused, the user can cause
1175 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1176 /// a menu with clipboard commands. See the
1177 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1178 /// for an example of how to use this signal.
1179 ///
1180 /// Action
1181 ///
1182 ///
1183 /// #### `property-notify-event`
1184 /// The ::property-notify-event signal will be emitted when a property on
1185 /// the `widget`'s window has been changed or deleted.
1186 ///
1187 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1188 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1189 ///
1190 ///
1191 ///
1192 ///
1193 /// #### `proximity-in-event`
1194 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1195 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1196 ///
1197 /// This signal will be sent to the grab widget if there is one.
1198 ///
1199 ///
1200 ///
1201 ///
1202 /// #### `proximity-out-event`
1203 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1204 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1205 ///
1206 /// This signal will be sent to the grab widget if there is one.
1207 ///
1208 ///
1209 ///
1210 ///
1211 /// #### `query-tooltip`
1212 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1213 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1214 /// focus in keyboard mode.
1215 ///
1216 /// Using the given coordinates, the signal handler should determine
1217 /// whether a tooltip should be shown for `widget`. If this is the case
1218 /// [`true`] should be returned, [`false`] otherwise. Note that if
1219 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1220 /// should not be used.
1221 ///
1222 /// The signal handler is free to manipulate `tooltip` with the therefore
1223 /// destined function calls.
1224 ///
1225 ///
1226 ///
1227 ///
1228 /// #### `realize`
1229 /// The ::realize signal is emitted when `widget` is associated with a
1230 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1231 /// widget has been mapped (that is, it is going to be drawn).
1232 ///
1233 ///
1234 ///
1235 ///
1236 /// #### `screen-changed`
1237 /// The ::screen-changed signal gets emitted when the
1238 /// screen of a widget has changed.
1239 ///
1240 ///
1241 ///
1242 ///
1243 /// #### `scroll-event`
1244 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1245 /// range is pressed. Wheel mice are usually configured to generate
1246 /// button press events for buttons 4 and 5 when the wheel is turned.
1247 ///
1248 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1249 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1250 ///
1251 /// This signal will be sent to the grab widget if there is one.
1252 ///
1253 ///
1254 ///
1255 ///
1256 /// #### `selection-clear-event`
1257 /// The ::selection-clear-event signal will be emitted when the
1258 /// the `widget`'s window has lost ownership of a selection.
1259 ///
1260 ///
1261 ///
1262 ///
1263 /// #### `selection-get`
1264 ///
1265 ///
1266 ///
1267 /// #### `selection-notify-event`
1268 ///
1269 ///
1270 ///
1271 /// #### `selection-received`
1272 ///
1273 ///
1274 ///
1275 /// #### `selection-request-event`
1276 /// The ::selection-request-event signal will be emitted when
1277 /// another client requests ownership of the selection owned by
1278 /// the `widget`'s window.
1279 ///
1280 ///
1281 ///
1282 ///
1283 /// #### `show`
1284 /// The ::show signal is emitted when `widget` is shown, for example with
1285 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1286 ///
1287 ///
1288 ///
1289 ///
1290 /// #### `show-help`
1291 /// Action
1292 ///
1293 ///
1294 /// #### `size-allocate`
1295 ///
1296 ///
1297 ///
1298 /// #### `state-changed`
1299 /// The ::state-changed signal is emitted when the widget state changes.
1300 /// See `gtk_widget_get_state()`.
1301 ///
1302 ///
1303 ///
1304 ///
1305 /// #### `state-flags-changed`
1306 /// The ::state-flags-changed signal is emitted when the widget state
1307 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1308 ///
1309 ///
1310 ///
1311 ///
1312 /// #### `style-set`
1313 /// The ::style-set signal is emitted when a new style has been set
1314 /// on a widget. Note that style-modifying functions like
1315 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1316 ///
1317 /// Note that this signal is emitted for changes to the deprecated
1318 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1319 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1320 ///
1321 ///
1322 ///
1323 ///
1324 /// #### `style-updated`
1325 /// The ::style-updated signal is a convenience signal that is emitted when the
1326 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1327 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1328 ///
1329 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1330 /// cause this signal to be emitted.
1331 ///
1332 ///
1333 ///
1334 ///
1335 /// #### `touch-event`
1336 ///
1337 ///
1338 ///
1339 /// #### `unmap`
1340 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1341 /// means that either it or any of its parents up to the toplevel widget have
1342 /// been set as hidden.
1343 ///
1344 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1345 /// used to, for example, stop an animation on the widget.
1346 ///
1347 ///
1348 ///
1349 ///
1350 /// #### `unmap-event`
1351 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1352 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1353 ///
1354 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1355 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1356 /// automatically for all new windows.
1357 ///
1358 ///
1359 ///
1360 ///
1361 /// #### `unrealize`
1362 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1363 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1364 /// called or the widget has been unmapped (that is, it is going to be
1365 /// hidden).
1366 ///
1367 ///
1368 ///
1369 ///
1370 /// #### `visibility-notify-event`
1371 /// The ::visibility-notify-event will be emitted when the `widget`'s
1372 /// window is obscured or unobscured.
1373 ///
1374 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1375 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1376 ///
1377 ///
1378 ///
1379 ///
1380 /// #### `window-state-event`
1381 /// The ::window-state-event will be emitted when the state of the
1382 /// toplevel window associated to the `widget` changes.
1383 ///
1384 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1385 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1386 /// this mask automatically for all new windows.
1387 ///
1388 ///
1389 /// </details>
1390 /// <details><summary><h4>CellEditable</h4></summary>
1391 ///
1392 ///
1393 /// #### `editing-done`
1394 /// This signal is a sign for the cell renderer to update its
1395 /// value from the `cell_editable`.
1396 ///
1397 /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
1398 /// emitting this signal when they are done editing, e.g.
1399 /// [`Entry`][crate::Entry] emits this signal when the user presses Enter. Typical things to
1400 /// do in a handler for ::editing-done are to capture the edited value,
1401 /// disconnect the `cell_editable` from signals on the [`CellRenderer`][crate::CellRenderer], etc.
1402 ///
1403 /// [`CellEditableExt::editing_done()`][crate::prelude::CellEditableExt::editing_done()] is a convenience method
1404 /// for emitting [`editing-done`][struct@crate::CellEditable#editing-done].
1405 ///
1406 ///
1407 ///
1408 ///
1409 /// #### `remove-widget`
1410 /// This signal is meant to indicate that the cell is finished
1411 /// editing, and the `cell_editable` widget is being removed and may
1412 /// subsequently be destroyed.
1413 ///
1414 /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
1415 /// emitting this signal when they are done editing. It must
1416 /// be emitted after the [`editing-done`][struct@crate::CellEditable#editing-done] signal,
1417 /// to give the cell renderer a chance to update the cell's value
1418 /// before the widget is removed.
1419 ///
1420 /// [`CellEditableExt::remove_widget()`][crate::prelude::CellEditableExt::remove_widget()] is a convenience method
1421 /// for emitting [`remove-widget`][struct@crate::CellEditable#remove-widget].
1422 ///
1423 ///
1424 /// </details>
1425 ///
1426 /// # Implements
1427 ///
1428 /// [`ComboBoxExt`][trait@crate::prelude::ComboBoxExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`CellEditableExt`][trait@crate::prelude::CellEditableExt], [`CellLayoutExt`][trait@crate::prelude::CellLayoutExt], [`ComboBoxExtManual`][trait@crate::prelude::ComboBoxExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1429 #[doc(alias = "GtkComboBox")]
1430 pub struct ComboBox(Object<ffi::GtkComboBox, ffi::GtkComboBoxClass>) @extends Bin, Container, Widget, @implements Buildable, CellEditable, CellLayout;
1431
1432 match fn {
1433 type_ => || ffi::gtk_combo_box_get_type(),
1434 }
1435}
1436
1437impl ComboBox {
1438 pub const NONE: Option<&'static ComboBox> = None;
1439
1440 /// Creates a new empty [`ComboBox`][crate::ComboBox].
1441 ///
1442 /// # Returns
1443 ///
1444 /// A new [`ComboBox`][crate::ComboBox].
1445 #[doc(alias = "gtk_combo_box_new")]
1446 pub fn new() -> ComboBox {
1447 assert_initialized_main_thread!();
1448 unsafe { Widget::from_glib_none(ffi::gtk_combo_box_new()).unsafe_cast() }
1449 }
1450
1451 /// Creates a new empty [`ComboBox`][crate::ComboBox] using `area` to layout cells.
1452 /// ## `area`
1453 /// the [`CellArea`][crate::CellArea] to use to layout cell renderers
1454 ///
1455 /// # Returns
1456 ///
1457 /// A new [`ComboBox`][crate::ComboBox].
1458 #[doc(alias = "gtk_combo_box_new_with_area")]
1459 #[doc(alias = "new_with_area")]
1460 pub fn with_area(area: &impl IsA<CellArea>) -> ComboBox {
1461 skip_assert_initialized!();
1462 unsafe {
1463 Widget::from_glib_none(ffi::gtk_combo_box_new_with_area(
1464 area.as_ref().to_glib_none().0,
1465 ))
1466 .unsafe_cast()
1467 }
1468 }
1469
1470 /// Creates a new empty [`ComboBox`][crate::ComboBox] with an entry.
1471 ///
1472 /// The new combo box will use `area` to layout cells.
1473 /// ## `area`
1474 /// the [`CellArea`][crate::CellArea] to use to layout cell renderers
1475 ///
1476 /// # Returns
1477 ///
1478 /// A new [`ComboBox`][crate::ComboBox].
1479 #[doc(alias = "gtk_combo_box_new_with_area_and_entry")]
1480 #[doc(alias = "new_with_area_and_entry")]
1481 pub fn with_area_and_entry(area: &impl IsA<CellArea>) -> ComboBox {
1482 skip_assert_initialized!();
1483 unsafe {
1484 Widget::from_glib_none(ffi::gtk_combo_box_new_with_area_and_entry(
1485 area.as_ref().to_glib_none().0,
1486 ))
1487 .unsafe_cast()
1488 }
1489 }
1490
1491 /// Creates a new empty [`ComboBox`][crate::ComboBox] with an entry.
1492 ///
1493 /// # Returns
1494 ///
1495 /// A new [`ComboBox`][crate::ComboBox].
1496 #[doc(alias = "gtk_combo_box_new_with_entry")]
1497 #[doc(alias = "new_with_entry")]
1498 pub fn with_entry() -> ComboBox {
1499 assert_initialized_main_thread!();
1500 unsafe { Widget::from_glib_none(ffi::gtk_combo_box_new_with_entry()).unsafe_cast() }
1501 }
1502
1503 /// Creates a new [`ComboBox`][crate::ComboBox] with the model initialized to `model`.
1504 /// ## `model`
1505 /// A [`TreeModel`][crate::TreeModel].
1506 ///
1507 /// # Returns
1508 ///
1509 /// A new [`ComboBox`][crate::ComboBox].
1510 #[doc(alias = "gtk_combo_box_new_with_model")]
1511 #[doc(alias = "new_with_model")]
1512 pub fn with_model(model: &impl IsA<TreeModel>) -> ComboBox {
1513 skip_assert_initialized!();
1514 unsafe {
1515 Widget::from_glib_none(ffi::gtk_combo_box_new_with_model(
1516 model.as_ref().to_glib_none().0,
1517 ))
1518 .unsafe_cast()
1519 }
1520 }
1521
1522 /// Creates a new empty [`ComboBox`][crate::ComboBox] with an entry
1523 /// and with the model initialized to `model`.
1524 /// ## `model`
1525 /// A [`TreeModel`][crate::TreeModel]
1526 ///
1527 /// # Returns
1528 ///
1529 /// A new [`ComboBox`][crate::ComboBox]
1530 #[doc(alias = "gtk_combo_box_new_with_model_and_entry")]
1531 #[doc(alias = "new_with_model_and_entry")]
1532 pub fn with_model_and_entry(model: &impl IsA<TreeModel>) -> ComboBox {
1533 skip_assert_initialized!();
1534 unsafe {
1535 Widget::from_glib_none(ffi::gtk_combo_box_new_with_model_and_entry(
1536 model.as_ref().to_glib_none().0,
1537 ))
1538 .unsafe_cast()
1539 }
1540 }
1541
1542 // rustdoc-stripper-ignore-next
1543 /// Creates a new builder-pattern struct instance to construct [`ComboBox`] objects.
1544 ///
1545 /// This method returns an instance of [`ComboBoxBuilder`](crate::builders::ComboBoxBuilder) which can be used to create [`ComboBox`] objects.
1546 pub fn builder() -> ComboBoxBuilder {
1547 ComboBoxBuilder::new()
1548 }
1549}
1550
1551impl Default for ComboBox {
1552 fn default() -> Self {
1553 Self::new()
1554 }
1555}
1556
1557// rustdoc-stripper-ignore-next
1558/// A [builder-pattern] type to construct [`ComboBox`] objects.
1559///
1560/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1561#[must_use = "The builder must be built to be used"]
1562pub struct ComboBoxBuilder {
1563 builder: glib::object::ObjectBuilder<'static, ComboBox>,
1564}
1565
1566impl ComboBoxBuilder {
1567 fn new() -> Self {
1568 Self {
1569 builder: glib::object::Object::builder(),
1570 }
1571 }
1572
1573 /// The item which is currently active. If the model is a non-flat treemodel,
1574 /// and the active item is not an immediate child of the root of the tree,
1575 /// this property has the value
1576 /// `gtk_tree_path_get_indices (path)[0]`,
1577 /// where `path` is the [`TreePath`][crate::TreePath] of the active item.
1578 pub fn active(self, active: i32) -> Self {
1579 Self {
1580 builder: self.builder.property("active", active),
1581 }
1582 }
1583
1584 /// The value of the ID column of the active row.
1585 pub fn active_id(self, active_id: impl Into<glib::GString>) -> Self {
1586 Self {
1587 builder: self.builder.property("active-id", active_id.into()),
1588 }
1589 }
1590
1591 /// Whether the dropdown button is sensitive when
1592 /// the model is empty.
1593 pub fn button_sensitivity(self, button_sensitivity: SensitivityType) -> Self {
1594 Self {
1595 builder: self
1596 .builder
1597 .property("button-sensitivity", button_sensitivity),
1598 }
1599 }
1600
1601 /// The [`CellArea`][crate::CellArea] used to layout cell renderers for this combo box.
1602 ///
1603 /// If no area is specified when creating the combo box with [`ComboBox::with_area()`][crate::ComboBox::with_area()]
1604 /// a horizontally oriented [`CellAreaBox`][crate::CellAreaBox] will be used.
1605 pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
1606 Self {
1607 builder: self
1608 .builder
1609 .property("cell-area", cell_area.clone().upcast()),
1610 }
1611 }
1612
1613 /// If this is set to a non-negative value, it must be the index of a column
1614 /// of type `G_TYPE_INT` in the model. The value in that column for each item
1615 /// will determine how many columns that item will span in the popup.
1616 /// Therefore, values in this column must be greater than zero, and the sum of
1617 /// an item’s column position + span should not exceed [`wrap-width`][struct@crate::ComboBox#wrap-width].
1618 pub fn column_span_column(self, column_span_column: i32) -> Self {
1619 Self {
1620 builder: self
1621 .builder
1622 .property("column-span-column", column_span_column),
1623 }
1624 }
1625
1626 /// The column in the combo box's model to associate with strings from the entry
1627 /// if the combo was created with [`has-entry`][struct@crate::ComboBox#has-entry] = [`true`].
1628 pub fn entry_text_column(self, entry_text_column: i32) -> Self {
1629 Self {
1630 builder: self
1631 .builder
1632 .property("entry-text-column", entry_text_column),
1633 }
1634 }
1635
1636 /// Whether the combo box has an entry.
1637 pub fn has_entry(self, has_entry: bool) -> Self {
1638 Self {
1639 builder: self.builder.property("has-entry", has_entry),
1640 }
1641 }
1642
1643 /// The has-frame property controls whether a frame
1644 /// is drawn around the entry.
1645 pub fn has_frame(self, has_frame: bool) -> Self {
1646 Self {
1647 builder: self.builder.property("has-frame", has_frame),
1648 }
1649 }
1650
1651 /// The column in the combo box's model that provides string
1652 /// IDs for the values in the model, if != -1.
1653 pub fn id_column(self, id_column: i32) -> Self {
1654 Self {
1655 builder: self.builder.property("id-column", id_column),
1656 }
1657 }
1658
1659 /// The model from which the combo box takes the values shown
1660 /// in the list.
1661 pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
1662 Self {
1663 builder: self.builder.property("model", model.clone().upcast()),
1664 }
1665 }
1666
1667 /// Whether the popup's width should be a fixed width matching the
1668 /// allocated width of the combo box.
1669 pub fn popup_fixed_width(self, popup_fixed_width: bool) -> Self {
1670 Self {
1671 builder: self
1672 .builder
1673 .property("popup-fixed-width", popup_fixed_width),
1674 }
1675 }
1676
1677 /// If this is set to a non-negative value, it must be the index of a column
1678 /// of type `G_TYPE_INT` in the model. The value in that column for each item
1679 /// will determine how many rows that item will span in the popup. Therefore,
1680 /// values in this column must be greater than zero.
1681 pub fn row_span_column(self, row_span_column: i32) -> Self {
1682 Self {
1683 builder: self.builder.property("row-span-column", row_span_column),
1684 }
1685 }
1686
1687 /// If wrap-width is set to a positive value, items in the popup will be laid
1688 /// out along multiple columns, starting a new row on reaching the wrap width.
1689 pub fn wrap_width(self, wrap_width: i32) -> Self {
1690 Self {
1691 builder: self.builder.property("wrap-width", wrap_width),
1692 }
1693 }
1694
1695 pub fn border_width(self, border_width: u32) -> Self {
1696 Self {
1697 builder: self.builder.property("border-width", border_width),
1698 }
1699 }
1700
1701 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1702 Self {
1703 builder: self.builder.property("child", child.clone().upcast()),
1704 }
1705 }
1706
1707 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1708 Self {
1709 builder: self.builder.property("resize-mode", resize_mode),
1710 }
1711 }
1712
1713 pub fn app_paintable(self, app_paintable: bool) -> Self {
1714 Self {
1715 builder: self.builder.property("app-paintable", app_paintable),
1716 }
1717 }
1718
1719 pub fn can_default(self, can_default: bool) -> Self {
1720 Self {
1721 builder: self.builder.property("can-default", can_default),
1722 }
1723 }
1724
1725 pub fn can_focus(self, can_focus: bool) -> Self {
1726 Self {
1727 builder: self.builder.property("can-focus", can_focus),
1728 }
1729 }
1730
1731 pub fn events(self, events: gdk::EventMask) -> Self {
1732 Self {
1733 builder: self.builder.property("events", events),
1734 }
1735 }
1736
1737 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1738 pub fn expand(self, expand: bool) -> Self {
1739 Self {
1740 builder: self.builder.property("expand", expand),
1741 }
1742 }
1743
1744 /// Whether the widget should grab focus when it is clicked with the mouse.
1745 ///
1746 /// This property is only relevant for widgets that can take focus.
1747 ///
1748 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1749 /// GtkComboBox) implemented this property individually.
1750 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1751 Self {
1752 builder: self.builder.property("focus-on-click", focus_on_click),
1753 }
1754 }
1755
1756 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1757 pub fn halign(self, halign: Align) -> Self {
1758 Self {
1759 builder: self.builder.property("halign", halign),
1760 }
1761 }
1762
1763 pub fn has_default(self, has_default: bool) -> Self {
1764 Self {
1765 builder: self.builder.property("has-default", has_default),
1766 }
1767 }
1768
1769 pub fn has_focus(self, has_focus: bool) -> Self {
1770 Self {
1771 builder: self.builder.property("has-focus", has_focus),
1772 }
1773 }
1774
1775 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1776 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1777 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1778 /// whether it will provide a tooltip or not.
1779 ///
1780 /// Note that setting this property to [`true`] for the first time will change
1781 /// the event masks of the GdkWindows of this widget to include leave-notify
1782 /// and motion-notify events. This cannot and will not be undone when the
1783 /// property is set to [`false`] again.
1784 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1785 Self {
1786 builder: self.builder.property("has-tooltip", has_tooltip),
1787 }
1788 }
1789
1790 pub fn height_request(self, height_request: i32) -> Self {
1791 Self {
1792 builder: self.builder.property("height-request", height_request),
1793 }
1794 }
1795
1796 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1797 pub fn hexpand(self, hexpand: bool) -> Self {
1798 Self {
1799 builder: self.builder.property("hexpand", hexpand),
1800 }
1801 }
1802
1803 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1804 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1805 Self {
1806 builder: self.builder.property("hexpand-set", hexpand_set),
1807 }
1808 }
1809
1810 pub fn is_focus(self, is_focus: bool) -> Self {
1811 Self {
1812 builder: self.builder.property("is-focus", is_focus),
1813 }
1814 }
1815
1816 /// Sets all four sides' margin at once. If read, returns max
1817 /// margin on any side.
1818 pub fn margin(self, margin: i32) -> Self {
1819 Self {
1820 builder: self.builder.property("margin", margin),
1821 }
1822 }
1823
1824 /// Margin on bottom side of widget.
1825 ///
1826 /// This property adds margin outside of the widget's normal size
1827 /// request, the margin will be added in addition to the size from
1828 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1829 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1830 Self {
1831 builder: self.builder.property("margin-bottom", margin_bottom),
1832 }
1833 }
1834
1835 /// Margin on end of widget, horizontally. This property supports
1836 /// left-to-right and right-to-left text directions.
1837 ///
1838 /// This property adds margin outside of the widget's normal size
1839 /// request, the margin will be added in addition to the size from
1840 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1841 pub fn margin_end(self, margin_end: i32) -> Self {
1842 Self {
1843 builder: self.builder.property("margin-end", margin_end),
1844 }
1845 }
1846
1847 /// Margin on start of widget, horizontally. This property supports
1848 /// left-to-right and right-to-left text directions.
1849 ///
1850 /// This property adds margin outside of the widget's normal size
1851 /// request, the margin will be added in addition to the size from
1852 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1853 pub fn margin_start(self, margin_start: i32) -> Self {
1854 Self {
1855 builder: self.builder.property("margin-start", margin_start),
1856 }
1857 }
1858
1859 /// Margin on top side of widget.
1860 ///
1861 /// This property adds margin outside of the widget's normal size
1862 /// request, the margin will be added in addition to the size from
1863 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1864 pub fn margin_top(self, margin_top: i32) -> Self {
1865 Self {
1866 builder: self.builder.property("margin-top", margin_top),
1867 }
1868 }
1869
1870 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1871 Self {
1872 builder: self.builder.property("name", name.into()),
1873 }
1874 }
1875
1876 pub fn no_show_all(self, no_show_all: bool) -> Self {
1877 Self {
1878 builder: self.builder.property("no-show-all", no_show_all),
1879 }
1880 }
1881
1882 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1883 /// more details about window opacity.
1884 ///
1885 /// Before 3.8 this was only available in GtkWindow
1886 pub fn opacity(self, opacity: f64) -> Self {
1887 Self {
1888 builder: self.builder.property("opacity", opacity),
1889 }
1890 }
1891
1892 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1893 Self {
1894 builder: self.builder.property("parent", parent.clone().upcast()),
1895 }
1896 }
1897
1898 pub fn receives_default(self, receives_default: bool) -> Self {
1899 Self {
1900 builder: self.builder.property("receives-default", receives_default),
1901 }
1902 }
1903
1904 pub fn sensitive(self, sensitive: bool) -> Self {
1905 Self {
1906 builder: self.builder.property("sensitive", sensitive),
1907 }
1908 }
1909
1910 /// Sets the text of tooltip to be the given string, which is marked up
1911 /// with the [Pango text markup language][PangoMarkupFormat].
1912 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1913 ///
1914 /// This is a convenience property which will take care of getting the
1915 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1916 /// will automatically be set to [`true`] and there will be taken care of
1917 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1918 ///
1919 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1920 /// are set, the last one wins.
1921 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1922 Self {
1923 builder: self
1924 .builder
1925 .property("tooltip-markup", tooltip_markup.into()),
1926 }
1927 }
1928
1929 /// Sets the text of tooltip to be the given string.
1930 ///
1931 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1932 ///
1933 /// This is a convenience property which will take care of getting the
1934 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1935 /// will automatically be set to [`true`] and there will be taken care of
1936 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1937 ///
1938 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1939 /// are set, the last one wins.
1940 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1941 Self {
1942 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1943 }
1944 }
1945
1946 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1947 pub fn valign(self, valign: Align) -> Self {
1948 Self {
1949 builder: self.builder.property("valign", valign),
1950 }
1951 }
1952
1953 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1954 pub fn vexpand(self, vexpand: bool) -> Self {
1955 Self {
1956 builder: self.builder.property("vexpand", vexpand),
1957 }
1958 }
1959
1960 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1961 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1962 Self {
1963 builder: self.builder.property("vexpand-set", vexpand_set),
1964 }
1965 }
1966
1967 pub fn visible(self, visible: bool) -> Self {
1968 Self {
1969 builder: self.builder.property("visible", visible),
1970 }
1971 }
1972
1973 pub fn width_request(self, width_request: i32) -> Self {
1974 Self {
1975 builder: self.builder.property("width-request", width_request),
1976 }
1977 }
1978
1979 /// Indicates whether editing on the cell has been canceled.
1980 pub fn editing_canceled(self, editing_canceled: bool) -> Self {
1981 Self {
1982 builder: self.builder.property("editing-canceled", editing_canceled),
1983 }
1984 }
1985
1986 // rustdoc-stripper-ignore-next
1987 /// Build the [`ComboBox`].
1988 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1989 pub fn build(self) -> ComboBox {
1990 assert_initialized_main_thread!();
1991 self.builder.build()
1992 }
1993}
1994
1995/// Trait containing all [`struct@ComboBox`] methods.
1996///
1997/// # Implementors
1998///
1999/// [`AppChooserButton`][struct@crate::AppChooserButton], [`ComboBoxText`][struct@crate::ComboBoxText], [`ComboBox`][struct@crate::ComboBox]
2000pub trait ComboBoxExt: IsA<ComboBox> + 'static {
2001 /// Returns the ID of the active row of `self`. This value is taken
2002 /// from the active row and the column specified by the [`id-column`][struct@crate::ComboBox#id-column]
2003 /// property of `self` (see [`set_id_column()`][Self::set_id_column()]).
2004 ///
2005 /// The returned value is an interned string which means that you can
2006 /// compare the pointer by value to other interned strings and that you
2007 /// must not free it.
2008 ///
2009 /// If the [`id-column`][struct@crate::ComboBox#id-column] property of `self` is not set, or if
2010 /// no row is active, or if the active row has a [`None`] ID value, then [`None`]
2011 /// is returned.
2012 ///
2013 /// # Returns
2014 ///
2015 /// the ID of the active row, or [`None`]
2016 #[doc(alias = "gtk_combo_box_get_active_id")]
2017 #[doc(alias = "get_active_id")]
2018 #[doc(alias = "active-id")]
2019 fn active_id(&self) -> Option<glib::GString> {
2020 unsafe {
2021 from_glib_none(ffi::gtk_combo_box_get_active_id(
2022 self.as_ref().to_glib_none().0,
2023 ))
2024 }
2025 }
2026
2027 /// Sets `iter` to point to the currently active item, if any item is active.
2028 /// Otherwise, `iter` is left unchanged.
2029 ///
2030 /// # Returns
2031 ///
2032 /// [`true`] if `iter` was set, [`false`] otherwise
2033 ///
2034 /// ## `iter`
2035 /// A [`TreeIter`][crate::TreeIter]
2036 #[doc(alias = "gtk_combo_box_get_active_iter")]
2037 #[doc(alias = "get_active_iter")]
2038 fn active_iter(&self) -> Option<TreeIter> {
2039 unsafe {
2040 let mut iter = TreeIter::uninitialized();
2041 let ret = from_glib(ffi::gtk_combo_box_get_active_iter(
2042 self.as_ref().to_glib_none().0,
2043 iter.to_glib_none_mut().0,
2044 ));
2045 if ret { Some(iter) } else { None }
2046 }
2047 }
2048
2049 /// Returns whether the combo box sets the dropdown button
2050 /// sensitive or not when there are no items in the model.
2051 ///
2052 /// # Returns
2053 ///
2054 /// [`SensitivityType::On`][crate::SensitivityType::On] if the dropdown button
2055 /// is sensitive when the model is empty, [`SensitivityType::Off`][crate::SensitivityType::Off]
2056 /// if the button is always insensitive or
2057 /// [`SensitivityType::Auto`][crate::SensitivityType::Auto] if it is only sensitive as long as
2058 /// the model has one item to be selected.
2059 #[doc(alias = "gtk_combo_box_get_button_sensitivity")]
2060 #[doc(alias = "get_button_sensitivity")]
2061 #[doc(alias = "button-sensitivity")]
2062 fn button_sensitivity(&self) -> SensitivityType {
2063 unsafe {
2064 from_glib(ffi::gtk_combo_box_get_button_sensitivity(
2065 self.as_ref().to_glib_none().0,
2066 ))
2067 }
2068 }
2069
2070 /// Returns the column with column span information for `self`.
2071 ///
2072 /// # Returns
2073 ///
2074 /// the column span column.
2075 #[doc(alias = "gtk_combo_box_get_column_span_column")]
2076 #[doc(alias = "get_column_span_column")]
2077 #[doc(alias = "column-span-column")]
2078 fn column_span_column(&self) -> i32 {
2079 unsafe { ffi::gtk_combo_box_get_column_span_column(self.as_ref().to_glib_none().0) }
2080 }
2081
2082 /// Returns the column which `self` is using to get the strings
2083 /// from to display in the internal entry.
2084 ///
2085 /// # Returns
2086 ///
2087 /// A column in the data source model of `self`.
2088 #[doc(alias = "gtk_combo_box_get_entry_text_column")]
2089 #[doc(alias = "get_entry_text_column")]
2090 #[doc(alias = "entry-text-column")]
2091 fn entry_text_column(&self) -> i32 {
2092 unsafe { ffi::gtk_combo_box_get_entry_text_column(self.as_ref().to_glib_none().0) }
2093 }
2094
2095 /// Returns whether the combo box has an entry.
2096 ///
2097 /// # Returns
2098 ///
2099 /// whether there is an entry in `self`.
2100 #[doc(alias = "gtk_combo_box_get_has_entry")]
2101 #[doc(alias = "get_has_entry")]
2102 #[doc(alias = "has-entry")]
2103 fn has_entry(&self) -> bool {
2104 unsafe {
2105 from_glib(ffi::gtk_combo_box_get_has_entry(
2106 self.as_ref().to_glib_none().0,
2107 ))
2108 }
2109 }
2110
2111 /// Returns the column which `self` is using to get string IDs
2112 /// for values from.
2113 ///
2114 /// # Returns
2115 ///
2116 /// A column in the data source model of `self`.
2117 #[doc(alias = "gtk_combo_box_get_id_column")]
2118 #[doc(alias = "get_id_column")]
2119 #[doc(alias = "id-column")]
2120 fn id_column(&self) -> i32 {
2121 unsafe { ffi::gtk_combo_box_get_id_column(self.as_ref().to_glib_none().0) }
2122 }
2123
2124 /// Returns the [`TreeModel`][crate::TreeModel] which is acting as data source for `self`.
2125 ///
2126 /// # Returns
2127 ///
2128 /// A [`TreeModel`][crate::TreeModel] which was passed
2129 /// during construction.
2130 #[doc(alias = "gtk_combo_box_get_model")]
2131 #[doc(alias = "get_model")]
2132 fn model(&self) -> Option<TreeModel> {
2133 unsafe { from_glib_none(ffi::gtk_combo_box_get_model(self.as_ref().to_glib_none().0)) }
2134 }
2135
2136 /// Gets the accessible object corresponding to the combo box’s popup.
2137 ///
2138 /// This function is mostly intended for use by accessibility technologies;
2139 /// applications should have little use for it.
2140 ///
2141 /// # Returns
2142 ///
2143 /// the accessible object corresponding
2144 /// to the combo box’s popup.
2145 #[doc(alias = "gtk_combo_box_get_popup_accessible")]
2146 #[doc(alias = "get_popup_accessible")]
2147 fn popup_accessible(&self) -> Option<atk::Object> {
2148 unsafe {
2149 from_glib_none(ffi::gtk_combo_box_get_popup_accessible(
2150 self.as_ref().to_glib_none().0,
2151 ))
2152 }
2153 }
2154
2155 /// Gets whether the popup uses a fixed width matching
2156 /// the allocated width of the combo box.
2157 ///
2158 /// # Returns
2159 ///
2160 /// [`true`] if the popup uses a fixed width
2161 #[doc(alias = "gtk_combo_box_get_popup_fixed_width")]
2162 #[doc(alias = "get_popup_fixed_width")]
2163 #[doc(alias = "popup-fixed-width")]
2164 fn is_popup_fixed_width(&self) -> bool {
2165 unsafe {
2166 from_glib(ffi::gtk_combo_box_get_popup_fixed_width(
2167 self.as_ref().to_glib_none().0,
2168 ))
2169 }
2170 }
2171
2172 //#[doc(alias = "gtk_combo_box_get_row_separator_func")]
2173 //#[doc(alias = "get_row_separator_func")]
2174 //fn row_separator_func(&self) -> Option<Box_<dyn Fn(&TreeModel, &TreeIter) -> bool + 'static>> {
2175 // unsafe { TODO: call ffi:gtk_combo_box_get_row_separator_func() }
2176 //}
2177
2178 /// Returns the column with row span information for `self`.
2179 ///
2180 /// # Returns
2181 ///
2182 /// the row span column.
2183 #[doc(alias = "gtk_combo_box_get_row_span_column")]
2184 #[doc(alias = "get_row_span_column")]
2185 #[doc(alias = "row-span-column")]
2186 fn row_span_column(&self) -> i32 {
2187 unsafe { ffi::gtk_combo_box_get_row_span_column(self.as_ref().to_glib_none().0) }
2188 }
2189
2190 /// Returns the wrap width which is used to determine the number of columns
2191 /// for the popup menu. If the wrap width is larger than 1, the combo box
2192 /// is in table mode.
2193 ///
2194 /// # Returns
2195 ///
2196 /// the wrap width.
2197 #[doc(alias = "gtk_combo_box_get_wrap_width")]
2198 #[doc(alias = "get_wrap_width")]
2199 #[doc(alias = "wrap-width")]
2200 fn wrap_width(&self) -> i32 {
2201 unsafe { ffi::gtk_combo_box_get_wrap_width(self.as_ref().to_glib_none().0) }
2202 }
2203
2204 /// Hides the menu or dropdown list of `self`.
2205 ///
2206 /// This function is mostly intended for use by accessibility technologies;
2207 /// applications should have little use for it.
2208 #[doc(alias = "gtk_combo_box_popdown")]
2209 fn popdown(&self) {
2210 unsafe {
2211 ffi::gtk_combo_box_popdown(self.as_ref().to_glib_none().0);
2212 }
2213 }
2214
2215 /// Pops up the menu or dropdown list of `self`.
2216 ///
2217 /// This function is mostly intended for use by accessibility technologies;
2218 /// applications should have little use for it.
2219 ///
2220 /// Before calling this, `self` must be mapped, or nothing will happen.
2221 #[doc(alias = "gtk_combo_box_popup")]
2222 fn popup(&self) {
2223 unsafe {
2224 ffi::gtk_combo_box_popup(self.as_ref().to_glib_none().0);
2225 }
2226 }
2227
2228 /// Pops up the menu or dropdown list of `self`, the popup window
2229 /// will be grabbed so only `device` and its associated pointer/keyboard
2230 /// are the only `GdkDevices` able to send events to it.
2231 /// ## `device`
2232 /// a [`gdk::Device`][crate::gdk::Device]
2233 #[doc(alias = "gtk_combo_box_popup_for_device")]
2234 fn popup_for_device(&self, device: &gdk::Device) {
2235 unsafe {
2236 ffi::gtk_combo_box_popup_for_device(
2237 self.as_ref().to_glib_none().0,
2238 device.to_glib_none().0,
2239 );
2240 }
2241 }
2242
2243 /// Changes the active row of `self` to the one that has an ID equal to
2244 /// `active_id`, or unsets the active row if `active_id` is [`None`]. Rows having
2245 /// a [`None`] ID string cannot be made active by this function.
2246 ///
2247 /// If the [`id-column`][struct@crate::ComboBox#id-column] property of `self` is unset or if no
2248 /// row has the given ID then the function does nothing and returns [`false`].
2249 /// ## `active_id`
2250 /// the ID of the row to select, or [`None`]
2251 ///
2252 /// # Returns
2253 ///
2254 /// [`true`] if a row with a matching ID was found. If a [`None`]
2255 /// `active_id` was given to unset the active row, the function
2256 /// always returns [`true`].
2257 #[doc(alias = "gtk_combo_box_set_active_id")]
2258 #[doc(alias = "active-id")]
2259 fn set_active_id(&self, active_id: Option<&str>) -> bool {
2260 unsafe {
2261 from_glib(ffi::gtk_combo_box_set_active_id(
2262 self.as_ref().to_glib_none().0,
2263 active_id.to_glib_none().0,
2264 ))
2265 }
2266 }
2267
2268 /// Sets the current active item to be the one referenced by `iter`, or
2269 /// unsets the active item if `iter` is [`None`].
2270 /// ## `iter`
2271 /// The [`TreeIter`][crate::TreeIter], or [`None`]
2272 #[doc(alias = "gtk_combo_box_set_active_iter")]
2273 fn set_active_iter(&self, iter: Option<&TreeIter>) {
2274 unsafe {
2275 ffi::gtk_combo_box_set_active_iter(
2276 self.as_ref().to_glib_none().0,
2277 mut_override(iter.to_glib_none().0),
2278 );
2279 }
2280 }
2281
2282 /// Sets whether the dropdown button of the combo box should be
2283 /// always sensitive ([`SensitivityType::On`][crate::SensitivityType::On]), never sensitive ([`SensitivityType::Off`][crate::SensitivityType::Off])
2284 /// or only if there is at least one item to display ([`SensitivityType::Auto`][crate::SensitivityType::Auto]).
2285 /// ## `sensitivity`
2286 /// specify the sensitivity of the dropdown button
2287 #[doc(alias = "gtk_combo_box_set_button_sensitivity")]
2288 #[doc(alias = "button-sensitivity")]
2289 fn set_button_sensitivity(&self, sensitivity: SensitivityType) {
2290 unsafe {
2291 ffi::gtk_combo_box_set_button_sensitivity(
2292 self.as_ref().to_glib_none().0,
2293 sensitivity.into_glib(),
2294 );
2295 }
2296 }
2297
2298 /// Sets the column with column span information for `self` to be
2299 /// `column_span`. The column span column contains integers which indicate
2300 /// how many columns an item should span.
2301 /// ## `column_span`
2302 /// A column in the model passed during construction
2303 #[doc(alias = "gtk_combo_box_set_column_span_column")]
2304 #[doc(alias = "column-span-column")]
2305 fn set_column_span_column(&self, column_span: i32) {
2306 unsafe {
2307 ffi::gtk_combo_box_set_column_span_column(self.as_ref().to_glib_none().0, column_span);
2308 }
2309 }
2310
2311 /// Sets the model column which `self` should use to get strings from
2312 /// to be `text_column`. The column `text_column` in the model of `self`
2313 /// must be of type `G_TYPE_STRING`.
2314 ///
2315 /// This is only relevant if `self` has been created with
2316 /// [`has-entry`][struct@crate::ComboBox#has-entry] as [`true`].
2317 /// ## `text_column`
2318 /// A column in `model` to get the strings from for
2319 /// the internal entry
2320 #[doc(alias = "gtk_combo_box_set_entry_text_column")]
2321 #[doc(alias = "entry-text-column")]
2322 fn set_entry_text_column(&self, text_column: i32) {
2323 unsafe {
2324 ffi::gtk_combo_box_set_entry_text_column(self.as_ref().to_glib_none().0, text_column);
2325 }
2326 }
2327
2328 /// Sets the model column which `self` should use to get string IDs
2329 /// for values from. The column `id_column` in the model of `self`
2330 /// must be of type `G_TYPE_STRING`.
2331 /// ## `id_column`
2332 /// A column in `model` to get string IDs for values from
2333 #[doc(alias = "gtk_combo_box_set_id_column")]
2334 #[doc(alias = "id-column")]
2335 fn set_id_column(&self, id_column: i32) {
2336 unsafe {
2337 ffi::gtk_combo_box_set_id_column(self.as_ref().to_glib_none().0, id_column);
2338 }
2339 }
2340
2341 /// Sets the model used by `self` to be `model`. Will unset a previously set
2342 /// model (if applicable). If model is [`None`], then it will unset the model.
2343 ///
2344 /// Note that this function does not clear the cell renderers, you have to
2345 /// call [`CellLayoutExt::clear()`][crate::prelude::CellLayoutExt::clear()] yourself if you need to set up different
2346 /// cell renderers for the new model.
2347 /// ## `model`
2348 /// A [`TreeModel`][crate::TreeModel]
2349 #[doc(alias = "gtk_combo_box_set_model")]
2350 #[doc(alias = "model")]
2351 fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
2352 unsafe {
2353 ffi::gtk_combo_box_set_model(
2354 self.as_ref().to_glib_none().0,
2355 model.map(|p| p.as_ref()).to_glib_none().0,
2356 );
2357 }
2358 }
2359
2360 /// Specifies whether the popup’s width should be a fixed width
2361 /// matching the allocated width of the combo box.
2362 /// ## `fixed`
2363 /// whether to use a fixed popup width
2364 #[doc(alias = "gtk_combo_box_set_popup_fixed_width")]
2365 #[doc(alias = "popup-fixed-width")]
2366 fn set_popup_fixed_width(&self, fixed: bool) {
2367 unsafe {
2368 ffi::gtk_combo_box_set_popup_fixed_width(
2369 self.as_ref().to_glib_none().0,
2370 fixed.into_glib(),
2371 );
2372 }
2373 }
2374
2375 /// Sets the row separator function, which is used to determine
2376 /// whether a row should be drawn as a separator. If the row separator
2377 /// function is [`None`], no separators are drawn. This is the default value.
2378 /// ## `func`
2379 /// a `GtkTreeViewRowSeparatorFunc`
2380 #[doc(alias = "gtk_combo_box_set_row_separator_func")]
2381 fn set_row_separator_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(&self, func: P) {
2382 let func_data: Box_<P> = Box_::new(func);
2383 unsafe extern "C" fn func_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(
2384 model: *mut ffi::GtkTreeModel,
2385 iter: *mut ffi::GtkTreeIter,
2386 data: glib::ffi::gpointer,
2387 ) -> glib::ffi::gboolean {
2388 unsafe {
2389 let model = from_glib_borrow(model);
2390 let iter = from_glib_borrow(iter);
2391 let callback = &*(data as *mut P);
2392 (*callback)(&model, &iter).into_glib()
2393 }
2394 }
2395 let func = Some(func_func::<P> as _);
2396 unsafe extern "C" fn destroy_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(
2397 data: glib::ffi::gpointer,
2398 ) {
2399 unsafe {
2400 let _callback = Box_::from_raw(data as *mut P);
2401 }
2402 }
2403 let destroy_call3 = Some(destroy_func::<P> as _);
2404 let super_callback0: Box_<P> = func_data;
2405 unsafe {
2406 ffi::gtk_combo_box_set_row_separator_func(
2407 self.as_ref().to_glib_none().0,
2408 func,
2409 Box_::into_raw(super_callback0) as *mut _,
2410 destroy_call3,
2411 );
2412 }
2413 }
2414
2415 /// Sets the column with row span information for `self` to be `row_span`.
2416 /// The row span column contains integers which indicate how many rows
2417 /// an item should span.
2418 /// ## `row_span`
2419 /// A column in the model passed during construction.
2420 #[doc(alias = "gtk_combo_box_set_row_span_column")]
2421 #[doc(alias = "row-span-column")]
2422 fn set_row_span_column(&self, row_span: i32) {
2423 unsafe {
2424 ffi::gtk_combo_box_set_row_span_column(self.as_ref().to_glib_none().0, row_span);
2425 }
2426 }
2427
2428 /// Sets the wrap width of `self` to be `width`. The wrap width is basically
2429 /// the preferred number of columns when you want the popup to be layed out
2430 /// in a table.
2431 /// ## `width`
2432 /// Preferred number of columns
2433 #[doc(alias = "gtk_combo_box_set_wrap_width")]
2434 #[doc(alias = "wrap-width")]
2435 fn set_wrap_width(&self, width: i32) {
2436 unsafe {
2437 ffi::gtk_combo_box_set_wrap_width(self.as_ref().to_glib_none().0, width);
2438 }
2439 }
2440
2441 /// The [`CellArea`][crate::CellArea] used to layout cell renderers for this combo box.
2442 ///
2443 /// If no area is specified when creating the combo box with [`ComboBox::with_area()`][crate::ComboBox::with_area()]
2444 /// a horizontally oriented [`CellAreaBox`][crate::CellAreaBox] will be used.
2445 #[doc(alias = "cell-area")]
2446 fn cell_area(&self) -> Option<CellArea> {
2447 ObjectExt::property(self.as_ref(), "cell-area")
2448 }
2449
2450 /// The has-frame property controls whether a frame
2451 /// is drawn around the entry.
2452 #[doc(alias = "has-frame")]
2453 fn has_frame(&self) -> bool {
2454 ObjectExt::property(self.as_ref(), "has-frame")
2455 }
2456
2457 /// The has-frame property controls whether a frame
2458 /// is drawn around the entry.
2459 #[doc(alias = "has-frame")]
2460 fn set_has_frame(&self, has_frame: bool) {
2461 ObjectExt::set_property(self.as_ref(), "has-frame", has_frame)
2462 }
2463
2464 /// Whether the combo boxes dropdown is popped up.
2465 /// Note that this property is mainly useful, because
2466 /// it allows you to connect to notify::popup-shown.
2467 #[doc(alias = "popup-shown")]
2468 fn is_popup_shown(&self) -> bool {
2469 ObjectExt::property(self.as_ref(), "popup-shown")
2470 }
2471
2472 /// The changed signal is emitted when the active
2473 /// item is changed. The can be due to the user selecting
2474 /// a different item from the list, or due to a
2475 /// call to [`set_active_iter()`][Self::set_active_iter()].
2476 /// It will also be emitted while typing into the entry of a combo box
2477 /// with an entry.
2478 #[doc(alias = "changed")]
2479 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2480 unsafe extern "C" fn changed_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2481 this: *mut ffi::GtkComboBox,
2482 f: glib::ffi::gpointer,
2483 ) {
2484 unsafe {
2485 let f: &F = &*(f as *const F);
2486 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2487 }
2488 }
2489 unsafe {
2490 let f: Box_<F> = Box_::new(f);
2491 connect_raw(
2492 self.as_ptr() as *mut _,
2493 c"changed".as_ptr(),
2494 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2495 changed_trampoline::<Self, F> as *const (),
2496 )),
2497 Box_::into_raw(f),
2498 )
2499 }
2500 }
2501
2502 /// For combo boxes that are created with an entry (See GtkComboBox:has-entry).
2503 ///
2504 /// A signal which allows you to change how the text displayed in a combo box's
2505 /// entry is displayed.
2506 ///
2507 /// Connect a signal handler which returns an allocated string representing
2508 /// `path`. That string will then be used to set the text in the combo box's entry.
2509 /// The default signal handler uses the text from the GtkComboBox::entry-text-column
2510 /// model column.
2511 ///
2512 /// Here's an example signal handler which fetches data from the model and
2513 /// displays it in the entry.
2514 ///
2515 ///
2516 /// **⚠️ The following code is in C ⚠️**
2517 ///
2518 /// ```C
2519 /// static gchar*
2520 /// format_entry_text_callback (GtkComboBox *combo,
2521 /// const gchar *path,
2522 /// gpointer user_data)
2523 /// {
2524 /// GtkTreeIter iter;
2525 /// GtkTreeModel model;
2526 /// gdouble value;
2527 ///
2528 /// model = gtk_combo_box_get_model (combo);
2529 ///
2530 /// gtk_tree_model_get_iter_from_string (model, &iter, path);
2531 /// gtk_tree_model_get (model, &iter,
2532 /// THE_DOUBLE_VALUE_COLUMN, &value,
2533 /// -1);
2534 ///
2535 /// return g_strdup_printf ("%g", value);
2536 /// }
2537 /// ```
2538 /// ## `path`
2539 /// the GtkTreePath string from the combo box's current model to format text for
2540 ///
2541 /// # Returns
2542 ///
2543 /// a newly allocated string representing `path`
2544 /// for the current GtkComboBox model.
2545 #[doc(alias = "format-entry-text")]
2546 fn connect_format_entry_text<F: Fn(&Self, &str) -> String + 'static>(
2547 &self,
2548 f: F,
2549 ) -> SignalHandlerId {
2550 unsafe extern "C" fn format_entry_text_trampoline<
2551 P: IsA<ComboBox>,
2552 F: Fn(&P, &str) -> String + 'static,
2553 >(
2554 this: *mut ffi::GtkComboBox,
2555 path: *mut std::ffi::c_char,
2556 f: glib::ffi::gpointer,
2557 ) -> *mut std::ffi::c_char {
2558 unsafe {
2559 let f: &F = &*(f as *const F);
2560 f(
2561 ComboBox::from_glib_borrow(this).unsafe_cast_ref(),
2562 &glib::GString::from_glib_borrow(path),
2563 )
2564 .to_glib_full()
2565 }
2566 }
2567 unsafe {
2568 let f: Box_<F> = Box_::new(f);
2569 connect_raw(
2570 self.as_ptr() as *mut _,
2571 c"format-entry-text".as_ptr(),
2572 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2573 format_entry_text_trampoline::<Self, F> as *const (),
2574 )),
2575 Box_::into_raw(f),
2576 )
2577 }
2578 }
2579
2580 /// The ::move-active signal is a
2581 /// [keybinding signal][GtkBindingSignal]
2582 /// which gets emitted to move the active selection.
2583 /// ## `scroll_type`
2584 /// a [`ScrollType`][crate::ScrollType]
2585 #[doc(alias = "move-active")]
2586 fn connect_move_active<F: Fn(&Self, ScrollType) + 'static>(&self, f: F) -> SignalHandlerId {
2587 unsafe extern "C" fn move_active_trampoline<
2588 P: IsA<ComboBox>,
2589 F: Fn(&P, ScrollType) + 'static,
2590 >(
2591 this: *mut ffi::GtkComboBox,
2592 scroll_type: ffi::GtkScrollType,
2593 f: glib::ffi::gpointer,
2594 ) {
2595 unsafe {
2596 let f: &F = &*(f as *const F);
2597 f(
2598 ComboBox::from_glib_borrow(this).unsafe_cast_ref(),
2599 from_glib(scroll_type),
2600 )
2601 }
2602 }
2603 unsafe {
2604 let f: Box_<F> = Box_::new(f);
2605 connect_raw(
2606 self.as_ptr() as *mut _,
2607 c"move-active".as_ptr(),
2608 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2609 move_active_trampoline::<Self, F> as *const (),
2610 )),
2611 Box_::into_raw(f),
2612 )
2613 }
2614 }
2615
2616 fn emit_move_active(&self, scroll_type: ScrollType) {
2617 self.emit_by_name::<()>("move-active", &[&scroll_type]);
2618 }
2619
2620 /// The ::popdown signal is a
2621 /// [keybinding signal][GtkBindingSignal]
2622 /// which gets emitted to popdown the combo box list.
2623 ///
2624 /// The default bindings for this signal are Alt+Up and Escape.
2625 #[doc(alias = "popdown")]
2626 fn connect_popdown<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
2627 unsafe extern "C" fn popdown_trampoline<P: IsA<ComboBox>, F: Fn(&P) -> bool + 'static>(
2628 this: *mut ffi::GtkComboBox,
2629 f: glib::ffi::gpointer,
2630 ) -> glib::ffi::gboolean {
2631 unsafe {
2632 let f: &F = &*(f as *const F);
2633 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
2634 }
2635 }
2636 unsafe {
2637 let f: Box_<F> = Box_::new(f);
2638 connect_raw(
2639 self.as_ptr() as *mut _,
2640 c"popdown".as_ptr(),
2641 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2642 popdown_trampoline::<Self, F> as *const (),
2643 )),
2644 Box_::into_raw(f),
2645 )
2646 }
2647 }
2648
2649 fn emit_popdown(&self) -> bool {
2650 self.emit_by_name("popdown", &[])
2651 }
2652
2653 /// The ::popup signal is a
2654 /// [keybinding signal][GtkBindingSignal]
2655 /// which gets emitted to popup the combo box list.
2656 ///
2657 /// The default binding for this signal is Alt+Down.
2658 #[doc(alias = "popup")]
2659 fn connect_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2660 unsafe extern "C" fn popup_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2661 this: *mut ffi::GtkComboBox,
2662 f: glib::ffi::gpointer,
2663 ) {
2664 unsafe {
2665 let f: &F = &*(f as *const F);
2666 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2667 }
2668 }
2669 unsafe {
2670 let f: Box_<F> = Box_::new(f);
2671 connect_raw(
2672 self.as_ptr() as *mut _,
2673 c"popup".as_ptr(),
2674 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2675 popup_trampoline::<Self, F> as *const (),
2676 )),
2677 Box_::into_raw(f),
2678 )
2679 }
2680 }
2681
2682 fn emit_popup(&self) {
2683 self.emit_by_name::<()>("popup", &[]);
2684 }
2685
2686 #[doc(alias = "active")]
2687 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2688 unsafe extern "C" fn notify_active_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2689 this: *mut ffi::GtkComboBox,
2690 _param_spec: glib::ffi::gpointer,
2691 f: glib::ffi::gpointer,
2692 ) {
2693 unsafe {
2694 let f: &F = &*(f as *const F);
2695 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2696 }
2697 }
2698 unsafe {
2699 let f: Box_<F> = Box_::new(f);
2700 connect_raw(
2701 self.as_ptr() as *mut _,
2702 c"notify::active".as_ptr(),
2703 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2704 notify_active_trampoline::<Self, F> as *const (),
2705 )),
2706 Box_::into_raw(f),
2707 )
2708 }
2709 }
2710
2711 #[doc(alias = "active-id")]
2712 fn connect_active_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2713 unsafe extern "C" fn notify_active_id_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2714 this: *mut ffi::GtkComboBox,
2715 _param_spec: glib::ffi::gpointer,
2716 f: glib::ffi::gpointer,
2717 ) {
2718 unsafe {
2719 let f: &F = &*(f as *const F);
2720 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2721 }
2722 }
2723 unsafe {
2724 let f: Box_<F> = Box_::new(f);
2725 connect_raw(
2726 self.as_ptr() as *mut _,
2727 c"notify::active-id".as_ptr(),
2728 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2729 notify_active_id_trampoline::<Self, F> as *const (),
2730 )),
2731 Box_::into_raw(f),
2732 )
2733 }
2734 }
2735
2736 #[doc(alias = "button-sensitivity")]
2737 fn connect_button_sensitivity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2738 unsafe extern "C" fn notify_button_sensitivity_trampoline<
2739 P: IsA<ComboBox>,
2740 F: Fn(&P) + 'static,
2741 >(
2742 this: *mut ffi::GtkComboBox,
2743 _param_spec: glib::ffi::gpointer,
2744 f: glib::ffi::gpointer,
2745 ) {
2746 unsafe {
2747 let f: &F = &*(f as *const F);
2748 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2749 }
2750 }
2751 unsafe {
2752 let f: Box_<F> = Box_::new(f);
2753 connect_raw(
2754 self.as_ptr() as *mut _,
2755 c"notify::button-sensitivity".as_ptr(),
2756 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2757 notify_button_sensitivity_trampoline::<Self, F> as *const (),
2758 )),
2759 Box_::into_raw(f),
2760 )
2761 }
2762 }
2763
2764 #[doc(alias = "column-span-column")]
2765 fn connect_column_span_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2766 unsafe extern "C" fn notify_column_span_column_trampoline<
2767 P: IsA<ComboBox>,
2768 F: Fn(&P) + 'static,
2769 >(
2770 this: *mut ffi::GtkComboBox,
2771 _param_spec: glib::ffi::gpointer,
2772 f: glib::ffi::gpointer,
2773 ) {
2774 unsafe {
2775 let f: &F = &*(f as *const F);
2776 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2777 }
2778 }
2779 unsafe {
2780 let f: Box_<F> = Box_::new(f);
2781 connect_raw(
2782 self.as_ptr() as *mut _,
2783 c"notify::column-span-column".as_ptr(),
2784 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2785 notify_column_span_column_trampoline::<Self, F> as *const (),
2786 )),
2787 Box_::into_raw(f),
2788 )
2789 }
2790 }
2791
2792 #[doc(alias = "entry-text-column")]
2793 fn connect_entry_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2794 unsafe extern "C" fn notify_entry_text_column_trampoline<
2795 P: IsA<ComboBox>,
2796 F: Fn(&P) + 'static,
2797 >(
2798 this: *mut ffi::GtkComboBox,
2799 _param_spec: glib::ffi::gpointer,
2800 f: glib::ffi::gpointer,
2801 ) {
2802 unsafe {
2803 let f: &F = &*(f as *const F);
2804 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2805 }
2806 }
2807 unsafe {
2808 let f: Box_<F> = Box_::new(f);
2809 connect_raw(
2810 self.as_ptr() as *mut _,
2811 c"notify::entry-text-column".as_ptr(),
2812 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2813 notify_entry_text_column_trampoline::<Self, F> as *const (),
2814 )),
2815 Box_::into_raw(f),
2816 )
2817 }
2818 }
2819
2820 #[doc(alias = "has-frame")]
2821 fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2822 unsafe extern "C" fn notify_has_frame_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2823 this: *mut ffi::GtkComboBox,
2824 _param_spec: glib::ffi::gpointer,
2825 f: glib::ffi::gpointer,
2826 ) {
2827 unsafe {
2828 let f: &F = &*(f as *const F);
2829 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2830 }
2831 }
2832 unsafe {
2833 let f: Box_<F> = Box_::new(f);
2834 connect_raw(
2835 self.as_ptr() as *mut _,
2836 c"notify::has-frame".as_ptr(),
2837 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2838 notify_has_frame_trampoline::<Self, F> as *const (),
2839 )),
2840 Box_::into_raw(f),
2841 )
2842 }
2843 }
2844
2845 #[doc(alias = "id-column")]
2846 fn connect_id_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2847 unsafe extern "C" fn notify_id_column_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2848 this: *mut ffi::GtkComboBox,
2849 _param_spec: glib::ffi::gpointer,
2850 f: glib::ffi::gpointer,
2851 ) {
2852 unsafe {
2853 let f: &F = &*(f as *const F);
2854 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2855 }
2856 }
2857 unsafe {
2858 let f: Box_<F> = Box_::new(f);
2859 connect_raw(
2860 self.as_ptr() as *mut _,
2861 c"notify::id-column".as_ptr(),
2862 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2863 notify_id_column_trampoline::<Self, F> as *const (),
2864 )),
2865 Box_::into_raw(f),
2866 )
2867 }
2868 }
2869
2870 #[doc(alias = "model")]
2871 fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2872 unsafe extern "C" fn notify_model_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2873 this: *mut ffi::GtkComboBox,
2874 _param_spec: glib::ffi::gpointer,
2875 f: glib::ffi::gpointer,
2876 ) {
2877 unsafe {
2878 let f: &F = &*(f as *const F);
2879 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2880 }
2881 }
2882 unsafe {
2883 let f: Box_<F> = Box_::new(f);
2884 connect_raw(
2885 self.as_ptr() as *mut _,
2886 c"notify::model".as_ptr(),
2887 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2888 notify_model_trampoline::<Self, F> as *const (),
2889 )),
2890 Box_::into_raw(f),
2891 )
2892 }
2893 }
2894
2895 #[doc(alias = "popup-fixed-width")]
2896 fn connect_popup_fixed_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2897 unsafe extern "C" fn notify_popup_fixed_width_trampoline<
2898 P: IsA<ComboBox>,
2899 F: Fn(&P) + 'static,
2900 >(
2901 this: *mut ffi::GtkComboBox,
2902 _param_spec: glib::ffi::gpointer,
2903 f: glib::ffi::gpointer,
2904 ) {
2905 unsafe {
2906 let f: &F = &*(f as *const F);
2907 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2908 }
2909 }
2910 unsafe {
2911 let f: Box_<F> = Box_::new(f);
2912 connect_raw(
2913 self.as_ptr() as *mut _,
2914 c"notify::popup-fixed-width".as_ptr(),
2915 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2916 notify_popup_fixed_width_trampoline::<Self, F> as *const (),
2917 )),
2918 Box_::into_raw(f),
2919 )
2920 }
2921 }
2922
2923 #[doc(alias = "popup-shown")]
2924 fn connect_popup_shown_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2925 unsafe extern "C" fn notify_popup_shown_trampoline<
2926 P: IsA<ComboBox>,
2927 F: Fn(&P) + 'static,
2928 >(
2929 this: *mut ffi::GtkComboBox,
2930 _param_spec: glib::ffi::gpointer,
2931 f: glib::ffi::gpointer,
2932 ) {
2933 unsafe {
2934 let f: &F = &*(f as *const F);
2935 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2936 }
2937 }
2938 unsafe {
2939 let f: Box_<F> = Box_::new(f);
2940 connect_raw(
2941 self.as_ptr() as *mut _,
2942 c"notify::popup-shown".as_ptr(),
2943 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2944 notify_popup_shown_trampoline::<Self, F> as *const (),
2945 )),
2946 Box_::into_raw(f),
2947 )
2948 }
2949 }
2950
2951 #[doc(alias = "row-span-column")]
2952 fn connect_row_span_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2953 unsafe extern "C" fn notify_row_span_column_trampoline<
2954 P: IsA<ComboBox>,
2955 F: Fn(&P) + 'static,
2956 >(
2957 this: *mut ffi::GtkComboBox,
2958 _param_spec: glib::ffi::gpointer,
2959 f: glib::ffi::gpointer,
2960 ) {
2961 unsafe {
2962 let f: &F = &*(f as *const F);
2963 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2964 }
2965 }
2966 unsafe {
2967 let f: Box_<F> = Box_::new(f);
2968 connect_raw(
2969 self.as_ptr() as *mut _,
2970 c"notify::row-span-column".as_ptr(),
2971 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2972 notify_row_span_column_trampoline::<Self, F> as *const (),
2973 )),
2974 Box_::into_raw(f),
2975 )
2976 }
2977 }
2978
2979 #[doc(alias = "wrap-width")]
2980 fn connect_wrap_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2981 unsafe extern "C" fn notify_wrap_width_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
2982 this: *mut ffi::GtkComboBox,
2983 _param_spec: glib::ffi::gpointer,
2984 f: glib::ffi::gpointer,
2985 ) {
2986 unsafe {
2987 let f: &F = &*(f as *const F);
2988 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
2989 }
2990 }
2991 unsafe {
2992 let f: Box_<F> = Box_::new(f);
2993 connect_raw(
2994 self.as_ptr() as *mut _,
2995 c"notify::wrap-width".as_ptr(),
2996 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2997 notify_wrap_width_trampoline::<Self, F> as *const (),
2998 )),
2999 Box_::into_raw(f),
3000 )
3001 }
3002 }
3003}
3004
3005impl<O: IsA<ComboBox>> ComboBoxExt for O {}