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