1#![allow(deprecated)]
5
6use crate::{
7 ffi, Accessible, AccessibleRole, Align, Buildable, CellEditable, CellLayout, ConstraintTarget,
8 LayoutManager, Overflow, ScrollType, SensitivityType, TreeIter, TreeModel, Widget,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 #[doc(alias = "GtkComboBox")]
20 pub struct ComboBox(Object<ffi::GtkComboBox, ffi::GtkComboBoxClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, CellEditable, CellLayout;
21
22 match fn {
23 type_ => || ffi::gtk_combo_box_get_type(),
24 }
25}
26
27impl ComboBox {
28 pub const NONE: Option<&'static ComboBox> = None;
29
30 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
31 #[allow(deprecated)]
32 #[doc(alias = "gtk_combo_box_new")]
33 pub fn new() -> ComboBox {
34 assert_initialized_main_thread!();
35 unsafe { Widget::from_glib_none(ffi::gtk_combo_box_new()).unsafe_cast() }
36 }
37
38 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
39 #[allow(deprecated)]
40 #[doc(alias = "gtk_combo_box_new_with_entry")]
41 #[doc(alias = "new_with_entry")]
42 pub fn with_entry() -> ComboBox {
43 assert_initialized_main_thread!();
44 unsafe { Widget::from_glib_none(ffi::gtk_combo_box_new_with_entry()).unsafe_cast() }
45 }
46
47 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
48 #[allow(deprecated)]
49 #[doc(alias = "gtk_combo_box_new_with_model")]
50 #[doc(alias = "new_with_model")]
51 pub fn with_model(model: &impl IsA<TreeModel>) -> ComboBox {
52 skip_assert_initialized!();
53 unsafe {
54 Widget::from_glib_none(ffi::gtk_combo_box_new_with_model(
55 model.as_ref().to_glib_none().0,
56 ))
57 .unsafe_cast()
58 }
59 }
60
61 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
62 #[allow(deprecated)]
63 #[doc(alias = "gtk_combo_box_new_with_model_and_entry")]
64 #[doc(alias = "new_with_model_and_entry")]
65 pub fn with_model_and_entry(model: &impl IsA<TreeModel>) -> ComboBox {
66 skip_assert_initialized!();
67 unsafe {
68 Widget::from_glib_none(ffi::gtk_combo_box_new_with_model_and_entry(
69 model.as_ref().to_glib_none().0,
70 ))
71 .unsafe_cast()
72 }
73 }
74
75 pub fn builder() -> ComboBoxBuilder {
80 ComboBoxBuilder::new()
81 }
82}
83
84impl Default for ComboBox {
85 fn default() -> Self {
86 Self::new()
87 }
88}
89
90#[must_use = "The builder must be built to be used"]
95pub struct ComboBoxBuilder {
96 builder: glib::object::ObjectBuilder<'static, ComboBox>,
97}
98
99impl ComboBoxBuilder {
100 fn new() -> Self {
101 Self {
102 builder: glib::object::Object::builder(),
103 }
104 }
105
106 pub fn active(self, active: i32) -> Self {
107 Self {
108 builder: self.builder.property("active", active),
109 }
110 }
111
112 pub fn active_id(self, active_id: impl Into<glib::GString>) -> Self {
113 Self {
114 builder: self.builder.property("active-id", active_id.into()),
115 }
116 }
117
118 pub fn button_sensitivity(self, button_sensitivity: SensitivityType) -> Self {
119 Self {
120 builder: self
121 .builder
122 .property("button-sensitivity", button_sensitivity),
123 }
124 }
125
126 pub fn child(self, child: &impl IsA<Widget>) -> Self {
127 Self {
128 builder: self.builder.property("child", child.clone().upcast()),
129 }
130 }
131
132 pub fn entry_text_column(self, entry_text_column: i32) -> Self {
133 Self {
134 builder: self
135 .builder
136 .property("entry-text-column", entry_text_column),
137 }
138 }
139
140 pub fn has_entry(self, has_entry: bool) -> Self {
141 Self {
142 builder: self.builder.property("has-entry", has_entry),
143 }
144 }
145
146 pub fn has_frame(self, has_frame: bool) -> Self {
147 Self {
148 builder: self.builder.property("has-frame", has_frame),
149 }
150 }
151
152 pub fn id_column(self, id_column: i32) -> Self {
153 Self {
154 builder: self.builder.property("id-column", id_column),
155 }
156 }
157
158 pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
159 Self {
160 builder: self.builder.property("model", model.clone().upcast()),
161 }
162 }
163
164 pub fn popup_fixed_width(self, popup_fixed_width: bool) -> Self {
165 Self {
166 builder: self
167 .builder
168 .property("popup-fixed-width", popup_fixed_width),
169 }
170 }
171
172 pub fn can_focus(self, can_focus: bool) -> Self {
173 Self {
174 builder: self.builder.property("can-focus", can_focus),
175 }
176 }
177
178 pub fn can_target(self, can_target: bool) -> Self {
179 Self {
180 builder: self.builder.property("can-target", can_target),
181 }
182 }
183
184 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
185 Self {
186 builder: self.builder.property("css-classes", css_classes.into()),
187 }
188 }
189
190 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
191 Self {
192 builder: self.builder.property("css-name", css_name.into()),
193 }
194 }
195
196 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
197 Self {
198 builder: self.builder.property("cursor", cursor.clone()),
199 }
200 }
201
202 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
203 Self {
204 builder: self.builder.property("focus-on-click", focus_on_click),
205 }
206 }
207
208 pub fn focusable(self, focusable: bool) -> Self {
209 Self {
210 builder: self.builder.property("focusable", focusable),
211 }
212 }
213
214 pub fn halign(self, halign: Align) -> Self {
215 Self {
216 builder: self.builder.property("halign", halign),
217 }
218 }
219
220 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
221 Self {
222 builder: self.builder.property("has-tooltip", has_tooltip),
223 }
224 }
225
226 pub fn height_request(self, height_request: i32) -> Self {
227 Self {
228 builder: self.builder.property("height-request", height_request),
229 }
230 }
231
232 pub fn hexpand(self, hexpand: bool) -> Self {
233 Self {
234 builder: self.builder.property("hexpand", hexpand),
235 }
236 }
237
238 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
239 Self {
240 builder: self.builder.property("hexpand-set", hexpand_set),
241 }
242 }
243
244 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
245 Self {
246 builder: self
247 .builder
248 .property("layout-manager", layout_manager.clone().upcast()),
249 }
250 }
251
252 #[cfg(feature = "v4_18")]
253 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
254 pub fn limit_events(self, limit_events: bool) -> Self {
255 Self {
256 builder: self.builder.property("limit-events", limit_events),
257 }
258 }
259
260 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
261 Self {
262 builder: self.builder.property("margin-bottom", margin_bottom),
263 }
264 }
265
266 pub fn margin_end(self, margin_end: i32) -> Self {
267 Self {
268 builder: self.builder.property("margin-end", margin_end),
269 }
270 }
271
272 pub fn margin_start(self, margin_start: i32) -> Self {
273 Self {
274 builder: self.builder.property("margin-start", margin_start),
275 }
276 }
277
278 pub fn margin_top(self, margin_top: i32) -> Self {
279 Self {
280 builder: self.builder.property("margin-top", margin_top),
281 }
282 }
283
284 pub fn name(self, name: impl Into<glib::GString>) -> Self {
285 Self {
286 builder: self.builder.property("name", name.into()),
287 }
288 }
289
290 pub fn opacity(self, opacity: f64) -> Self {
291 Self {
292 builder: self.builder.property("opacity", opacity),
293 }
294 }
295
296 pub fn overflow(self, overflow: Overflow) -> Self {
297 Self {
298 builder: self.builder.property("overflow", overflow),
299 }
300 }
301
302 pub fn receives_default(self, receives_default: bool) -> Self {
303 Self {
304 builder: self.builder.property("receives-default", receives_default),
305 }
306 }
307
308 pub fn sensitive(self, sensitive: bool) -> Self {
309 Self {
310 builder: self.builder.property("sensitive", sensitive),
311 }
312 }
313
314 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
315 Self {
316 builder: self
317 .builder
318 .property("tooltip-markup", tooltip_markup.into()),
319 }
320 }
321
322 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
323 Self {
324 builder: self.builder.property("tooltip-text", tooltip_text.into()),
325 }
326 }
327
328 pub fn valign(self, valign: Align) -> Self {
329 Self {
330 builder: self.builder.property("valign", valign),
331 }
332 }
333
334 pub fn vexpand(self, vexpand: bool) -> Self {
335 Self {
336 builder: self.builder.property("vexpand", vexpand),
337 }
338 }
339
340 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
341 Self {
342 builder: self.builder.property("vexpand-set", vexpand_set),
343 }
344 }
345
346 pub fn visible(self, visible: bool) -> Self {
347 Self {
348 builder: self.builder.property("visible", visible),
349 }
350 }
351
352 pub fn width_request(self, width_request: i32) -> Self {
353 Self {
354 builder: self.builder.property("width-request", width_request),
355 }
356 }
357
358 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
359 Self {
360 builder: self.builder.property("accessible-role", accessible_role),
361 }
362 }
363
364 pub fn editing_canceled(self, editing_canceled: bool) -> Self {
365 Self {
366 builder: self.builder.property("editing-canceled", editing_canceled),
367 }
368 }
369
370 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
373 pub fn build(self) -> ComboBox {
374 assert_initialized_main_thread!();
375 self.builder.build()
376 }
377}
378
379pub trait ComboBoxExt: IsA<ComboBox> + 'static {
380 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
381 #[allow(deprecated)]
382 #[doc(alias = "gtk_combo_box_get_active_id")]
383 #[doc(alias = "get_active_id")]
384 #[doc(alias = "active-id")]
385 fn active_id(&self) -> Option<glib::GString> {
386 unsafe {
387 from_glib_none(ffi::gtk_combo_box_get_active_id(
388 self.as_ref().to_glib_none().0,
389 ))
390 }
391 }
392
393 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
394 #[allow(deprecated)]
395 #[doc(alias = "gtk_combo_box_get_active_iter")]
396 #[doc(alias = "get_active_iter")]
397 fn active_iter(&self) -> Option<TreeIter> {
398 unsafe {
399 let mut iter = TreeIter::uninitialized();
400 let ret = from_glib(ffi::gtk_combo_box_get_active_iter(
401 self.as_ref().to_glib_none().0,
402 iter.to_glib_none_mut().0,
403 ));
404 if ret {
405 Some(iter)
406 } else {
407 None
408 }
409 }
410 }
411
412 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
413 #[allow(deprecated)]
414 #[doc(alias = "gtk_combo_box_get_button_sensitivity")]
415 #[doc(alias = "get_button_sensitivity")]
416 #[doc(alias = "button-sensitivity")]
417 fn button_sensitivity(&self) -> SensitivityType {
418 unsafe {
419 from_glib(ffi::gtk_combo_box_get_button_sensitivity(
420 self.as_ref().to_glib_none().0,
421 ))
422 }
423 }
424
425 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
426 #[allow(deprecated)]
427 #[doc(alias = "gtk_combo_box_get_child")]
428 #[doc(alias = "get_child")]
429 fn child(&self) -> Option<Widget> {
430 unsafe { from_glib_none(ffi::gtk_combo_box_get_child(self.as_ref().to_glib_none().0)) }
431 }
432
433 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
434 #[allow(deprecated)]
435 #[doc(alias = "gtk_combo_box_get_entry_text_column")]
436 #[doc(alias = "get_entry_text_column")]
437 #[doc(alias = "entry-text-column")]
438 fn entry_text_column(&self) -> i32 {
439 unsafe { ffi::gtk_combo_box_get_entry_text_column(self.as_ref().to_glib_none().0) }
440 }
441
442 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
443 #[allow(deprecated)]
444 #[doc(alias = "gtk_combo_box_get_has_entry")]
445 #[doc(alias = "get_has_entry")]
446 #[doc(alias = "has-entry")]
447 fn has_entry(&self) -> bool {
448 unsafe {
449 from_glib(ffi::gtk_combo_box_get_has_entry(
450 self.as_ref().to_glib_none().0,
451 ))
452 }
453 }
454
455 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
456 #[allow(deprecated)]
457 #[doc(alias = "gtk_combo_box_get_id_column")]
458 #[doc(alias = "get_id_column")]
459 #[doc(alias = "id-column")]
460 fn id_column(&self) -> i32 {
461 unsafe { ffi::gtk_combo_box_get_id_column(self.as_ref().to_glib_none().0) }
462 }
463
464 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
465 #[allow(deprecated)]
466 #[doc(alias = "gtk_combo_box_get_model")]
467 #[doc(alias = "get_model")]
468 fn model(&self) -> Option<TreeModel> {
469 unsafe { from_glib_none(ffi::gtk_combo_box_get_model(self.as_ref().to_glib_none().0)) }
470 }
471
472 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
473 #[allow(deprecated)]
474 #[doc(alias = "gtk_combo_box_get_popup_fixed_width")]
475 #[doc(alias = "get_popup_fixed_width")]
476 #[doc(alias = "popup-fixed-width")]
477 fn is_popup_fixed_width(&self) -> bool {
478 unsafe {
479 from_glib(ffi::gtk_combo_box_get_popup_fixed_width(
480 self.as_ref().to_glib_none().0,
481 ))
482 }
483 }
484
485 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
486 #[allow(deprecated)]
487 #[doc(alias = "gtk_combo_box_popdown")]
488 fn popdown(&self) {
489 unsafe {
490 ffi::gtk_combo_box_popdown(self.as_ref().to_glib_none().0);
491 }
492 }
493
494 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
495 #[allow(deprecated)]
496 #[doc(alias = "gtk_combo_box_popup")]
497 fn popup(&self) {
498 unsafe {
499 ffi::gtk_combo_box_popup(self.as_ref().to_glib_none().0);
500 }
501 }
502
503 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
504 #[allow(deprecated)]
505 #[doc(alias = "gtk_combo_box_popup_for_device")]
506 fn popup_for_device(&self, device: &gdk::Device) {
507 unsafe {
508 ffi::gtk_combo_box_popup_for_device(
509 self.as_ref().to_glib_none().0,
510 device.to_glib_none().0,
511 );
512 }
513 }
514
515 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
516 #[allow(deprecated)]
517 #[doc(alias = "gtk_combo_box_set_active_id")]
518 #[doc(alias = "active-id")]
519 fn set_active_id(&self, active_id: Option<&str>) -> bool {
520 unsafe {
521 from_glib(ffi::gtk_combo_box_set_active_id(
522 self.as_ref().to_glib_none().0,
523 active_id.to_glib_none().0,
524 ))
525 }
526 }
527
528 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
529 #[allow(deprecated)]
530 #[doc(alias = "gtk_combo_box_set_active_iter")]
531 fn set_active_iter(&self, iter: Option<&TreeIter>) {
532 unsafe {
533 ffi::gtk_combo_box_set_active_iter(
534 self.as_ref().to_glib_none().0,
535 mut_override(iter.to_glib_none().0),
536 );
537 }
538 }
539
540 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
541 #[allow(deprecated)]
542 #[doc(alias = "gtk_combo_box_set_button_sensitivity")]
543 #[doc(alias = "button-sensitivity")]
544 fn set_button_sensitivity(&self, sensitivity: SensitivityType) {
545 unsafe {
546 ffi::gtk_combo_box_set_button_sensitivity(
547 self.as_ref().to_glib_none().0,
548 sensitivity.into_glib(),
549 );
550 }
551 }
552
553 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
554 #[allow(deprecated)]
555 #[doc(alias = "gtk_combo_box_set_child")]
556 #[doc(alias = "child")]
557 fn set_child(&self, child: Option<&impl IsA<Widget>>) {
558 unsafe {
559 ffi::gtk_combo_box_set_child(
560 self.as_ref().to_glib_none().0,
561 child.map(|p| p.as_ref()).to_glib_none().0,
562 );
563 }
564 }
565
566 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
567 #[allow(deprecated)]
568 #[doc(alias = "gtk_combo_box_set_entry_text_column")]
569 #[doc(alias = "entry-text-column")]
570 fn set_entry_text_column(&self, text_column: i32) {
571 unsafe {
572 ffi::gtk_combo_box_set_entry_text_column(self.as_ref().to_glib_none().0, text_column);
573 }
574 }
575
576 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
577 #[allow(deprecated)]
578 #[doc(alias = "gtk_combo_box_set_id_column")]
579 #[doc(alias = "id-column")]
580 fn set_id_column(&self, id_column: i32) {
581 unsafe {
582 ffi::gtk_combo_box_set_id_column(self.as_ref().to_glib_none().0, id_column);
583 }
584 }
585
586 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
587 #[allow(deprecated)]
588 #[doc(alias = "gtk_combo_box_set_model")]
589 #[doc(alias = "model")]
590 fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
591 unsafe {
592 ffi::gtk_combo_box_set_model(
593 self.as_ref().to_glib_none().0,
594 model.map(|p| p.as_ref()).to_glib_none().0,
595 );
596 }
597 }
598
599 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
600 #[allow(deprecated)]
601 #[doc(alias = "gtk_combo_box_set_popup_fixed_width")]
602 #[doc(alias = "popup-fixed-width")]
603 fn set_popup_fixed_width(&self, fixed: bool) {
604 unsafe {
605 ffi::gtk_combo_box_set_popup_fixed_width(
606 self.as_ref().to_glib_none().0,
607 fixed.into_glib(),
608 );
609 }
610 }
611
612 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
613 #[allow(deprecated)]
614 #[doc(alias = "gtk_combo_box_set_row_separator_func")]
615 fn set_row_separator_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(&self, func: P) {
616 let func_data: Box_<P> = Box_::new(func);
617 unsafe extern "C" fn func_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(
618 model: *mut ffi::GtkTreeModel,
619 iter: *mut ffi::GtkTreeIter,
620 data: glib::ffi::gpointer,
621 ) -> glib::ffi::gboolean {
622 let model = from_glib_borrow(model);
623 let iter = from_glib_borrow(iter);
624 let callback = &*(data as *mut P);
625 (*callback)(&model, &iter).into_glib()
626 }
627 let func = Some(func_func::<P> as _);
628 unsafe extern "C" fn destroy_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(
629 data: glib::ffi::gpointer,
630 ) {
631 let _callback = Box_::from_raw(data as *mut P);
632 }
633 let destroy_call3 = Some(destroy_func::<P> as _);
634 let super_callback0: Box_<P> = func_data;
635 unsafe {
636 ffi::gtk_combo_box_set_row_separator_func(
637 self.as_ref().to_glib_none().0,
638 func,
639 Box_::into_raw(super_callback0) as *mut _,
640 destroy_call3,
641 );
642 }
643 }
644
645 #[doc(alias = "has-frame")]
646 fn has_frame(&self) -> bool {
647 ObjectExt::property(self.as_ref(), "has-frame")
648 }
649
650 #[doc(alias = "has-frame")]
651 fn set_has_frame(&self, has_frame: bool) {
652 ObjectExt::set_property(self.as_ref(), "has-frame", has_frame)
653 }
654
655 #[doc(alias = "popup-shown")]
656 fn is_popup_shown(&self) -> bool {
657 ObjectExt::property(self.as_ref(), "popup-shown")
658 }
659
660 #[cfg(feature = "v4_6")]
661 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
662 #[doc(alias = "activate")]
663 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
664 unsafe extern "C" fn activate_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
665 this: *mut ffi::GtkComboBox,
666 f: glib::ffi::gpointer,
667 ) {
668 let f: &F = &*(f as *const F);
669 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
670 }
671 unsafe {
672 let f: Box_<F> = Box_::new(f);
673 connect_raw(
674 self.as_ptr() as *mut _,
675 c"activate".as_ptr() as *const _,
676 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
677 activate_trampoline::<Self, F> as *const (),
678 )),
679 Box_::into_raw(f),
680 )
681 }
682 }
683
684 #[cfg(feature = "v4_6")]
685 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
686 fn emit_activate(&self) {
687 self.emit_by_name::<()>("activate", &[]);
688 }
689
690 #[doc(alias = "changed")]
691 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
692 unsafe extern "C" fn changed_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
693 this: *mut ffi::GtkComboBox,
694 f: glib::ffi::gpointer,
695 ) {
696 let f: &F = &*(f as *const F);
697 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
698 }
699 unsafe {
700 let f: Box_<F> = Box_::new(f);
701 connect_raw(
702 self.as_ptr() as *mut _,
703 c"changed".as_ptr() as *const _,
704 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
705 changed_trampoline::<Self, F> as *const (),
706 )),
707 Box_::into_raw(f),
708 )
709 }
710 }
711
712 #[doc(alias = "format-entry-text")]
713 fn connect_format_entry_text<F: Fn(&Self, &str) -> String + 'static>(
714 &self,
715 f: F,
716 ) -> SignalHandlerId {
717 unsafe extern "C" fn format_entry_text_trampoline<
718 P: IsA<ComboBox>,
719 F: Fn(&P, &str) -> String + 'static,
720 >(
721 this: *mut ffi::GtkComboBox,
722 path: *mut std::ffi::c_char,
723 f: glib::ffi::gpointer,
724 ) -> *mut std::ffi::c_char {
725 let f: &F = &*(f as *const F);
726 f(
727 ComboBox::from_glib_borrow(this).unsafe_cast_ref(),
728 &glib::GString::from_glib_borrow(path),
729 )
730 .to_glib_full()
731 }
732 unsafe {
733 let f: Box_<F> = Box_::new(f);
734 connect_raw(
735 self.as_ptr() as *mut _,
736 c"format-entry-text".as_ptr() as *const _,
737 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
738 format_entry_text_trampoline::<Self, F> as *const (),
739 )),
740 Box_::into_raw(f),
741 )
742 }
743 }
744
745 #[doc(alias = "move-active")]
746 fn connect_move_active<F: Fn(&Self, ScrollType) + 'static>(&self, f: F) -> SignalHandlerId {
747 unsafe extern "C" fn move_active_trampoline<
748 P: IsA<ComboBox>,
749 F: Fn(&P, ScrollType) + 'static,
750 >(
751 this: *mut ffi::GtkComboBox,
752 scroll_type: ffi::GtkScrollType,
753 f: glib::ffi::gpointer,
754 ) {
755 let f: &F = &*(f as *const F);
756 f(
757 ComboBox::from_glib_borrow(this).unsafe_cast_ref(),
758 from_glib(scroll_type),
759 )
760 }
761 unsafe {
762 let f: Box_<F> = Box_::new(f);
763 connect_raw(
764 self.as_ptr() as *mut _,
765 c"move-active".as_ptr() as *const _,
766 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
767 move_active_trampoline::<Self, F> as *const (),
768 )),
769 Box_::into_raw(f),
770 )
771 }
772 }
773
774 fn emit_move_active(&self, scroll_type: ScrollType) {
775 self.emit_by_name::<()>("move-active", &[&scroll_type]);
776 }
777
778 #[doc(alias = "popdown")]
779 fn connect_popdown<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
780 unsafe extern "C" fn popdown_trampoline<P: IsA<ComboBox>, F: Fn(&P) -> bool + 'static>(
781 this: *mut ffi::GtkComboBox,
782 f: glib::ffi::gpointer,
783 ) -> glib::ffi::gboolean {
784 let f: &F = &*(f as *const F);
785 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
786 }
787 unsafe {
788 let f: Box_<F> = Box_::new(f);
789 connect_raw(
790 self.as_ptr() as *mut _,
791 c"popdown".as_ptr() as *const _,
792 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
793 popdown_trampoline::<Self, F> as *const (),
794 )),
795 Box_::into_raw(f),
796 )
797 }
798 }
799
800 fn emit_popdown(&self) -> bool {
801 self.emit_by_name("popdown", &[])
802 }
803
804 #[doc(alias = "popup")]
805 fn connect_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
806 unsafe extern "C" fn popup_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
807 this: *mut ffi::GtkComboBox,
808 f: glib::ffi::gpointer,
809 ) {
810 let f: &F = &*(f as *const F);
811 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
812 }
813 unsafe {
814 let f: Box_<F> = Box_::new(f);
815 connect_raw(
816 self.as_ptr() as *mut _,
817 c"popup".as_ptr() as *const _,
818 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
819 popup_trampoline::<Self, F> as *const (),
820 )),
821 Box_::into_raw(f),
822 )
823 }
824 }
825
826 fn emit_popup(&self) {
827 self.emit_by_name::<()>("popup", &[]);
828 }
829
830 #[doc(alias = "active")]
831 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
832 unsafe extern "C" fn notify_active_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
833 this: *mut ffi::GtkComboBox,
834 _param_spec: glib::ffi::gpointer,
835 f: glib::ffi::gpointer,
836 ) {
837 let f: &F = &*(f as *const F);
838 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
839 }
840 unsafe {
841 let f: Box_<F> = Box_::new(f);
842 connect_raw(
843 self.as_ptr() as *mut _,
844 c"notify::active".as_ptr() as *const _,
845 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
846 notify_active_trampoline::<Self, F> as *const (),
847 )),
848 Box_::into_raw(f),
849 )
850 }
851 }
852
853 #[doc(alias = "active-id")]
854 fn connect_active_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
855 unsafe extern "C" fn notify_active_id_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
856 this: *mut ffi::GtkComboBox,
857 _param_spec: glib::ffi::gpointer,
858 f: glib::ffi::gpointer,
859 ) {
860 let f: &F = &*(f as *const F);
861 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
862 }
863 unsafe {
864 let f: Box_<F> = Box_::new(f);
865 connect_raw(
866 self.as_ptr() as *mut _,
867 c"notify::active-id".as_ptr() as *const _,
868 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
869 notify_active_id_trampoline::<Self, F> as *const (),
870 )),
871 Box_::into_raw(f),
872 )
873 }
874 }
875
876 #[doc(alias = "button-sensitivity")]
877 fn connect_button_sensitivity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
878 unsafe extern "C" fn notify_button_sensitivity_trampoline<
879 P: IsA<ComboBox>,
880 F: Fn(&P) + 'static,
881 >(
882 this: *mut ffi::GtkComboBox,
883 _param_spec: glib::ffi::gpointer,
884 f: glib::ffi::gpointer,
885 ) {
886 let f: &F = &*(f as *const F);
887 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
888 }
889 unsafe {
890 let f: Box_<F> = Box_::new(f);
891 connect_raw(
892 self.as_ptr() as *mut _,
893 c"notify::button-sensitivity".as_ptr() as *const _,
894 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
895 notify_button_sensitivity_trampoline::<Self, F> as *const (),
896 )),
897 Box_::into_raw(f),
898 )
899 }
900 }
901
902 #[doc(alias = "child")]
903 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
904 unsafe extern "C" fn notify_child_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
905 this: *mut ffi::GtkComboBox,
906 _param_spec: glib::ffi::gpointer,
907 f: glib::ffi::gpointer,
908 ) {
909 let f: &F = &*(f as *const F);
910 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
911 }
912 unsafe {
913 let f: Box_<F> = Box_::new(f);
914 connect_raw(
915 self.as_ptr() as *mut _,
916 c"notify::child".as_ptr() as *const _,
917 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
918 notify_child_trampoline::<Self, F> as *const (),
919 )),
920 Box_::into_raw(f),
921 )
922 }
923 }
924
925 #[doc(alias = "entry-text-column")]
926 fn connect_entry_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
927 unsafe extern "C" fn notify_entry_text_column_trampoline<
928 P: IsA<ComboBox>,
929 F: Fn(&P) + 'static,
930 >(
931 this: *mut ffi::GtkComboBox,
932 _param_spec: glib::ffi::gpointer,
933 f: glib::ffi::gpointer,
934 ) {
935 let f: &F = &*(f as *const F);
936 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
937 }
938 unsafe {
939 let f: Box_<F> = Box_::new(f);
940 connect_raw(
941 self.as_ptr() as *mut _,
942 c"notify::entry-text-column".as_ptr() as *const _,
943 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
944 notify_entry_text_column_trampoline::<Self, F> as *const (),
945 )),
946 Box_::into_raw(f),
947 )
948 }
949 }
950
951 #[doc(alias = "has-frame")]
952 fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
953 unsafe extern "C" fn notify_has_frame_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
954 this: *mut ffi::GtkComboBox,
955 _param_spec: glib::ffi::gpointer,
956 f: glib::ffi::gpointer,
957 ) {
958 let f: &F = &*(f as *const F);
959 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
960 }
961 unsafe {
962 let f: Box_<F> = Box_::new(f);
963 connect_raw(
964 self.as_ptr() as *mut _,
965 c"notify::has-frame".as_ptr() as *const _,
966 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
967 notify_has_frame_trampoline::<Self, F> as *const (),
968 )),
969 Box_::into_raw(f),
970 )
971 }
972 }
973
974 #[doc(alias = "id-column")]
975 fn connect_id_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
976 unsafe extern "C" fn notify_id_column_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
977 this: *mut ffi::GtkComboBox,
978 _param_spec: glib::ffi::gpointer,
979 f: glib::ffi::gpointer,
980 ) {
981 let f: &F = &*(f as *const F);
982 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
983 }
984 unsafe {
985 let f: Box_<F> = Box_::new(f);
986 connect_raw(
987 self.as_ptr() as *mut _,
988 c"notify::id-column".as_ptr() as *const _,
989 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
990 notify_id_column_trampoline::<Self, F> as *const (),
991 )),
992 Box_::into_raw(f),
993 )
994 }
995 }
996
997 #[doc(alias = "model")]
998 fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
999 unsafe extern "C" fn notify_model_trampoline<P: IsA<ComboBox>, F: Fn(&P) + 'static>(
1000 this: *mut ffi::GtkComboBox,
1001 _param_spec: glib::ffi::gpointer,
1002 f: glib::ffi::gpointer,
1003 ) {
1004 let f: &F = &*(f as *const F);
1005 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
1006 }
1007 unsafe {
1008 let f: Box_<F> = Box_::new(f);
1009 connect_raw(
1010 self.as_ptr() as *mut _,
1011 c"notify::model".as_ptr() as *const _,
1012 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1013 notify_model_trampoline::<Self, F> as *const (),
1014 )),
1015 Box_::into_raw(f),
1016 )
1017 }
1018 }
1019
1020 #[doc(alias = "popup-fixed-width")]
1021 fn connect_popup_fixed_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1022 unsafe extern "C" fn notify_popup_fixed_width_trampoline<
1023 P: IsA<ComboBox>,
1024 F: Fn(&P) + 'static,
1025 >(
1026 this: *mut ffi::GtkComboBox,
1027 _param_spec: glib::ffi::gpointer,
1028 f: glib::ffi::gpointer,
1029 ) {
1030 let f: &F = &*(f as *const F);
1031 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
1032 }
1033 unsafe {
1034 let f: Box_<F> = Box_::new(f);
1035 connect_raw(
1036 self.as_ptr() as *mut _,
1037 c"notify::popup-fixed-width".as_ptr() as *const _,
1038 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1039 notify_popup_fixed_width_trampoline::<Self, F> as *const (),
1040 )),
1041 Box_::into_raw(f),
1042 )
1043 }
1044 }
1045
1046 #[doc(alias = "popup-shown")]
1047 fn connect_popup_shown_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1048 unsafe extern "C" fn notify_popup_shown_trampoline<
1049 P: IsA<ComboBox>,
1050 F: Fn(&P) + 'static,
1051 >(
1052 this: *mut ffi::GtkComboBox,
1053 _param_spec: glib::ffi::gpointer,
1054 f: glib::ffi::gpointer,
1055 ) {
1056 let f: &F = &*(f as *const F);
1057 f(ComboBox::from_glib_borrow(this).unsafe_cast_ref())
1058 }
1059 unsafe {
1060 let f: Box_<F> = Box_::new(f);
1061 connect_raw(
1062 self.as_ptr() as *mut _,
1063 c"notify::popup-shown".as_ptr() as *const _,
1064 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1065 notify_popup_shown_trampoline::<Self, F> as *const (),
1066 )),
1067 Box_::into_raw(f),
1068 )
1069 }
1070 }
1071}
1072
1073impl<O: IsA<ComboBox>> ComboBoxExt for O {}