1use glib::object::Cast;
6use glib::object::IsA;
7use glib::signal::connect_raw;
8use glib::signal::SignalHandlerId;
9use glib::translate::*;
10use glib::GString;
11use glib::StaticType;
12use glib::ToValue;
13use glib::Value;
14use glib_sys;
15use gobject_sys;
16use gtk_sys;
17use libc;
18use signal::Inhibit;
19use std::boxed::Box as Box_;
20use std::fmt;
21use std::mem::transmute;
22use Buildable;
23use CellArea;
24use CellLayout;
25use TreeIter;
26use TreeModel;
27
28glib_wrapper! {
29 pub struct EntryCompletion(Object<gtk_sys::GtkEntryCompletion, gtk_sys::GtkEntryCompletionClass, EntryCompletionClass>) @implements Buildable, CellLayout;
30
31 match fn {
32 get_type => || gtk_sys::gtk_entry_completion_get_type(),
33 }
34}
35
36impl EntryCompletion {
37 pub fn new() -> EntryCompletion {
38 assert_initialized_main_thread!();
39 unsafe { from_glib_full(gtk_sys::gtk_entry_completion_new()) }
40 }
41
42 pub fn new_with_area<P: IsA<CellArea>>(area: &P) -> EntryCompletion {
43 skip_assert_initialized!();
44 unsafe {
45 from_glib_full(gtk_sys::gtk_entry_completion_new_with_area(
46 area.as_ref().to_glib_none().0,
47 ))
48 }
49 }
50}
51
52impl Default for EntryCompletion {
53 fn default() -> Self {
54 Self::new()
55 }
56}
57
58pub struct EntryCompletionBuilder {
59 cell_area: Option<CellArea>,
60 inline_completion: Option<bool>,
61 inline_selection: Option<bool>,
62 minimum_key_length: Option<i32>,
63 model: Option<TreeModel>,
64 popup_completion: Option<bool>,
65 popup_set_width: Option<bool>,
66 popup_single_match: Option<bool>,
67 text_column: Option<i32>,
68}
69
70impl EntryCompletionBuilder {
71 pub fn new() -> Self {
72 Self {
73 cell_area: None,
74 inline_completion: None,
75 inline_selection: None,
76 minimum_key_length: None,
77 model: None,
78 popup_completion: None,
79 popup_set_width: None,
80 popup_single_match: None,
81 text_column: None,
82 }
83 }
84
85 pub fn build(self) -> EntryCompletion {
86 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
87 if let Some(ref cell_area) = self.cell_area {
88 properties.push(("cell-area", cell_area));
89 }
90 if let Some(ref inline_completion) = self.inline_completion {
91 properties.push(("inline-completion", inline_completion));
92 }
93 if let Some(ref inline_selection) = self.inline_selection {
94 properties.push(("inline-selection", inline_selection));
95 }
96 if let Some(ref minimum_key_length) = self.minimum_key_length {
97 properties.push(("minimum-key-length", minimum_key_length));
98 }
99 if let Some(ref model) = self.model {
100 properties.push(("model", model));
101 }
102 if let Some(ref popup_completion) = self.popup_completion {
103 properties.push(("popup-completion", popup_completion));
104 }
105 if let Some(ref popup_set_width) = self.popup_set_width {
106 properties.push(("popup-set-width", popup_set_width));
107 }
108 if let Some(ref popup_single_match) = self.popup_single_match {
109 properties.push(("popup-single-match", popup_single_match));
110 }
111 if let Some(ref text_column) = self.text_column {
112 properties.push(("text-column", text_column));
113 }
114 glib::Object::new(EntryCompletion::static_type(), &properties)
115 .expect("object new")
116 .downcast()
117 .expect("downcast")
118 }
119
120 pub fn cell_area(mut self, cell_area: &CellArea) -> Self {
121 self.cell_area = Some(cell_area.clone());
122 self
123 }
124
125 pub fn inline_completion(mut self, inline_completion: bool) -> Self {
126 self.inline_completion = Some(inline_completion);
127 self
128 }
129
130 pub fn inline_selection(mut self, inline_selection: bool) -> Self {
131 self.inline_selection = Some(inline_selection);
132 self
133 }
134
135 pub fn minimum_key_length(mut self, minimum_key_length: i32) -> Self {
136 self.minimum_key_length = Some(minimum_key_length);
137 self
138 }
139
140 pub fn model(mut self, model: &TreeModel) -> Self {
141 self.model = Some(model.clone());
142 self
143 }
144
145 pub fn popup_completion(mut self, popup_completion: bool) -> Self {
146 self.popup_completion = Some(popup_completion);
147 self
148 }
149
150 pub fn popup_set_width(mut self, popup_set_width: bool) -> Self {
151 self.popup_set_width = Some(popup_set_width);
152 self
153 }
154
155 pub fn popup_single_match(mut self, popup_single_match: bool) -> Self {
156 self.popup_single_match = Some(popup_single_match);
157 self
158 }
159
160 pub fn text_column(mut self, text_column: i32) -> Self {
161 self.text_column = Some(text_column);
162 self
163 }
164}
165
166pub const NONE_ENTRY_COMPLETION: Option<&EntryCompletion> = None;
167
168pub trait EntryCompletionExt: 'static {
169 fn complete(&self);
170
171 fn compute_prefix(&self, key: &str) -> Option<GString>;
172
173 fn delete_action(&self, index_: i32);
174
175 fn get_completion_prefix(&self) -> Option<GString>;
176
177 fn get_inline_completion(&self) -> bool;
178
179 fn get_inline_selection(&self) -> bool;
180
181 fn get_minimum_key_length(&self) -> i32;
182
183 fn get_model(&self) -> Option<TreeModel>;
184
185 fn get_popup_completion(&self) -> bool;
186
187 fn get_popup_set_width(&self) -> bool;
188
189 fn get_popup_single_match(&self) -> bool;
190
191 fn get_text_column(&self) -> i32;
192
193 fn insert_action_markup(&self, index_: i32, markup: &str);
194
195 fn insert_action_text(&self, index_: i32, text: &str);
196
197 fn insert_prefix(&self);
198
199 fn set_inline_completion(&self, inline_completion: bool);
200
201 fn set_inline_selection(&self, inline_selection: bool);
202
203 fn set_match_func<P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static>(&self, func: P);
204
205 fn set_minimum_key_length(&self, length: i32);
206
207 fn set_model<P: IsA<TreeModel>>(&self, model: Option<&P>);
208
209 fn set_popup_completion(&self, popup_completion: bool);
210
211 fn set_popup_set_width(&self, popup_set_width: bool);
212
213 fn set_popup_single_match(&self, popup_single_match: bool);
214
215 fn set_text_column(&self, column: i32);
216
217 fn get_property_cell_area(&self) -> Option<CellArea>;
218
219 fn connect_action_activated<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId;
220
221 fn connect_cursor_on_match<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(
222 &self,
223 f: F,
224 ) -> SignalHandlerId;
225
226 fn connect_insert_prefix<F: Fn(&Self, &str) -> Inhibit + 'static>(
227 &self,
228 f: F,
229 ) -> SignalHandlerId;
230
231 fn connect_match_selected<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(
232 &self,
233 f: F,
234 ) -> SignalHandlerId;
235
236 fn connect_no_matches<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
237
238 fn connect_property_inline_completion_notify<F: Fn(&Self) + 'static>(
239 &self,
240 f: F,
241 ) -> SignalHandlerId;
242
243 fn connect_property_inline_selection_notify<F: Fn(&Self) + 'static>(
244 &self,
245 f: F,
246 ) -> SignalHandlerId;
247
248 fn connect_property_minimum_key_length_notify<F: Fn(&Self) + 'static>(
249 &self,
250 f: F,
251 ) -> SignalHandlerId;
252
253 fn connect_property_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
254
255 fn connect_property_popup_completion_notify<F: Fn(&Self) + 'static>(
256 &self,
257 f: F,
258 ) -> SignalHandlerId;
259
260 fn connect_property_popup_set_width_notify<F: Fn(&Self) + 'static>(
261 &self,
262 f: F,
263 ) -> SignalHandlerId;
264
265 fn connect_property_popup_single_match_notify<F: Fn(&Self) + 'static>(
266 &self,
267 f: F,
268 ) -> SignalHandlerId;
269
270 fn connect_property_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
271}
272
273impl<O: IsA<EntryCompletion>> EntryCompletionExt for O {
274 fn complete(&self) {
275 unsafe {
276 gtk_sys::gtk_entry_completion_complete(self.as_ref().to_glib_none().0);
277 }
278 }
279
280 fn compute_prefix(&self, key: &str) -> Option<GString> {
281 unsafe {
282 from_glib_full(gtk_sys::gtk_entry_completion_compute_prefix(
283 self.as_ref().to_glib_none().0,
284 key.to_glib_none().0,
285 ))
286 }
287 }
288
289 fn delete_action(&self, index_: i32) {
290 unsafe {
291 gtk_sys::gtk_entry_completion_delete_action(self.as_ref().to_glib_none().0, index_);
292 }
293 }
294
295 fn get_completion_prefix(&self) -> Option<GString> {
296 unsafe {
297 from_glib_none(gtk_sys::gtk_entry_completion_get_completion_prefix(
298 self.as_ref().to_glib_none().0,
299 ))
300 }
301 }
302
303 fn get_inline_completion(&self) -> bool {
304 unsafe {
305 from_glib(gtk_sys::gtk_entry_completion_get_inline_completion(
306 self.as_ref().to_glib_none().0,
307 ))
308 }
309 }
310
311 fn get_inline_selection(&self) -> bool {
312 unsafe {
313 from_glib(gtk_sys::gtk_entry_completion_get_inline_selection(
314 self.as_ref().to_glib_none().0,
315 ))
316 }
317 }
318
319 fn get_minimum_key_length(&self) -> i32 {
320 unsafe {
321 gtk_sys::gtk_entry_completion_get_minimum_key_length(self.as_ref().to_glib_none().0)
322 }
323 }
324
325 fn get_model(&self) -> Option<TreeModel> {
326 unsafe {
327 from_glib_none(gtk_sys::gtk_entry_completion_get_model(
328 self.as_ref().to_glib_none().0,
329 ))
330 }
331 }
332
333 fn get_popup_completion(&self) -> bool {
334 unsafe {
335 from_glib(gtk_sys::gtk_entry_completion_get_popup_completion(
336 self.as_ref().to_glib_none().0,
337 ))
338 }
339 }
340
341 fn get_popup_set_width(&self) -> bool {
342 unsafe {
343 from_glib(gtk_sys::gtk_entry_completion_get_popup_set_width(
344 self.as_ref().to_glib_none().0,
345 ))
346 }
347 }
348
349 fn get_popup_single_match(&self) -> bool {
350 unsafe {
351 from_glib(gtk_sys::gtk_entry_completion_get_popup_single_match(
352 self.as_ref().to_glib_none().0,
353 ))
354 }
355 }
356
357 fn get_text_column(&self) -> i32 {
358 unsafe { gtk_sys::gtk_entry_completion_get_text_column(self.as_ref().to_glib_none().0) }
359 }
360
361 fn insert_action_markup(&self, index_: i32, markup: &str) {
362 unsafe {
363 gtk_sys::gtk_entry_completion_insert_action_markup(
364 self.as_ref().to_glib_none().0,
365 index_,
366 markup.to_glib_none().0,
367 );
368 }
369 }
370
371 fn insert_action_text(&self, index_: i32, text: &str) {
372 unsafe {
373 gtk_sys::gtk_entry_completion_insert_action_text(
374 self.as_ref().to_glib_none().0,
375 index_,
376 text.to_glib_none().0,
377 );
378 }
379 }
380
381 fn insert_prefix(&self) {
382 unsafe {
383 gtk_sys::gtk_entry_completion_insert_prefix(self.as_ref().to_glib_none().0);
384 }
385 }
386
387 fn set_inline_completion(&self, inline_completion: bool) {
388 unsafe {
389 gtk_sys::gtk_entry_completion_set_inline_completion(
390 self.as_ref().to_glib_none().0,
391 inline_completion.to_glib(),
392 );
393 }
394 }
395
396 fn set_inline_selection(&self, inline_selection: bool) {
397 unsafe {
398 gtk_sys::gtk_entry_completion_set_inline_selection(
399 self.as_ref().to_glib_none().0,
400 inline_selection.to_glib(),
401 );
402 }
403 }
404
405 fn set_match_func<P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static>(&self, func: P) {
406 let func_data: Box_<P> = Box::new(func);
407 unsafe extern "C" fn func_func<
408 P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static,
409 >(
410 completion: *mut gtk_sys::GtkEntryCompletion,
411 key: *const libc::c_char,
412 iter: *mut gtk_sys::GtkTreeIter,
413 user_data: glib_sys::gpointer,
414 ) -> glib_sys::gboolean {
415 let completion = from_glib_borrow(completion);
416 let key: GString = from_glib_borrow(key);
417 let iter = from_glib_borrow(iter);
418 let callback: &P = &*(user_data as *mut _);
419 let res = (*callback)(&completion, key.as_str(), &iter);
420 res.to_glib()
421 }
422 let func = Some(func_func::<P> as _);
423 unsafe extern "C" fn func_notify_func<
424 P: Fn(&EntryCompletion, &str, &TreeIter) -> bool + 'static,
425 >(
426 data: glib_sys::gpointer,
427 ) {
428 let _callback: Box_<P> = Box_::from_raw(data as *mut _);
429 }
430 let destroy_call3 = Some(func_notify_func::<P> as _);
431 let super_callback0: Box_<P> = func_data;
432 unsafe {
433 gtk_sys::gtk_entry_completion_set_match_func(
434 self.as_ref().to_glib_none().0,
435 func,
436 Box::into_raw(super_callback0) as *mut _,
437 destroy_call3,
438 );
439 }
440 }
441
442 fn set_minimum_key_length(&self, length: i32) {
443 unsafe {
444 gtk_sys::gtk_entry_completion_set_minimum_key_length(
445 self.as_ref().to_glib_none().0,
446 length,
447 );
448 }
449 }
450
451 fn set_model<P: IsA<TreeModel>>(&self, model: Option<&P>) {
452 unsafe {
453 gtk_sys::gtk_entry_completion_set_model(
454 self.as_ref().to_glib_none().0,
455 model.map(|p| p.as_ref()).to_glib_none().0,
456 );
457 }
458 }
459
460 fn set_popup_completion(&self, popup_completion: bool) {
461 unsafe {
462 gtk_sys::gtk_entry_completion_set_popup_completion(
463 self.as_ref().to_glib_none().0,
464 popup_completion.to_glib(),
465 );
466 }
467 }
468
469 fn set_popup_set_width(&self, popup_set_width: bool) {
470 unsafe {
471 gtk_sys::gtk_entry_completion_set_popup_set_width(
472 self.as_ref().to_glib_none().0,
473 popup_set_width.to_glib(),
474 );
475 }
476 }
477
478 fn set_popup_single_match(&self, popup_single_match: bool) {
479 unsafe {
480 gtk_sys::gtk_entry_completion_set_popup_single_match(
481 self.as_ref().to_glib_none().0,
482 popup_single_match.to_glib(),
483 );
484 }
485 }
486
487 fn set_text_column(&self, column: i32) {
488 unsafe {
489 gtk_sys::gtk_entry_completion_set_text_column(self.as_ref().to_glib_none().0, column);
490 }
491 }
492
493 fn get_property_cell_area(&self) -> Option<CellArea> {
494 unsafe {
495 let mut value = Value::from_type(<CellArea as StaticType>::static_type());
496 gobject_sys::g_object_get_property(
497 self.to_glib_none().0 as *mut gobject_sys::GObject,
498 b"cell-area\0".as_ptr() as *const _,
499 value.to_glib_none_mut().0,
500 );
501 value.get()
502 }
503 }
504
505 fn connect_action_activated<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
506 unsafe extern "C" fn action_activated_trampoline<P, F: Fn(&P, i32) + 'static>(
507 this: *mut gtk_sys::GtkEntryCompletion,
508 index: libc::c_int,
509 f: glib_sys::gpointer,
510 ) where
511 P: IsA<EntryCompletion>,
512 {
513 let f: &F = &*(f as *const F);
514 f(
515 &EntryCompletion::from_glib_borrow(this).unsafe_cast(),
516 index,
517 )
518 }
519 unsafe {
520 let f: Box_<F> = Box_::new(f);
521 connect_raw(
522 self.as_ptr() as *mut _,
523 b"action-activated\0".as_ptr() as *const _,
524 Some(transmute(action_activated_trampoline::<Self, F> as usize)),
525 Box_::into_raw(f),
526 )
527 }
528 }
529
530 fn connect_cursor_on_match<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(
531 &self,
532 f: F,
533 ) -> SignalHandlerId {
534 unsafe extern "C" fn cursor_on_match_trampoline<
535 P,
536 F: Fn(&P, &TreeModel, &TreeIter) -> Inhibit + 'static,
537 >(
538 this: *mut gtk_sys::GtkEntryCompletion,
539 model: *mut gtk_sys::GtkTreeModel,
540 iter: *mut gtk_sys::GtkTreeIter,
541 f: glib_sys::gpointer,
542 ) -> glib_sys::gboolean
543 where
544 P: IsA<EntryCompletion>,
545 {
546 let f: &F = &*(f as *const F);
547 f(
548 &EntryCompletion::from_glib_borrow(this).unsafe_cast(),
549 &from_glib_borrow(model),
550 &from_glib_borrow(iter),
551 )
552 .to_glib()
553 }
554 unsafe {
555 let f: Box_<F> = Box_::new(f);
556 connect_raw(
557 self.as_ptr() as *mut _,
558 b"cursor-on-match\0".as_ptr() as *const _,
559 Some(transmute(cursor_on_match_trampoline::<Self, F> as usize)),
560 Box_::into_raw(f),
561 )
562 }
563 }
564
565 fn connect_insert_prefix<F: Fn(&Self, &str) -> Inhibit + 'static>(
566 &self,
567 f: F,
568 ) -> SignalHandlerId {
569 unsafe extern "C" fn insert_prefix_trampoline<P, F: Fn(&P, &str) -> Inhibit + 'static>(
570 this: *mut gtk_sys::GtkEntryCompletion,
571 prefix: *mut libc::c_char,
572 f: glib_sys::gpointer,
573 ) -> glib_sys::gboolean
574 where
575 P: IsA<EntryCompletion>,
576 {
577 let f: &F = &*(f as *const F);
578 f(
579 &EntryCompletion::from_glib_borrow(this).unsafe_cast(),
580 &GString::from_glib_borrow(prefix),
581 )
582 .to_glib()
583 }
584 unsafe {
585 let f: Box_<F> = Box_::new(f);
586 connect_raw(
587 self.as_ptr() as *mut _,
588 b"insert-prefix\0".as_ptr() as *const _,
589 Some(transmute(insert_prefix_trampoline::<Self, F> as usize)),
590 Box_::into_raw(f),
591 )
592 }
593 }
594
595 fn connect_match_selected<F: Fn(&Self, &TreeModel, &TreeIter) -> Inhibit + 'static>(
596 &self,
597 f: F,
598 ) -> SignalHandlerId {
599 unsafe extern "C" fn match_selected_trampoline<
600 P,
601 F: Fn(&P, &TreeModel, &TreeIter) -> Inhibit + 'static,
602 >(
603 this: *mut gtk_sys::GtkEntryCompletion,
604 model: *mut gtk_sys::GtkTreeModel,
605 iter: *mut gtk_sys::GtkTreeIter,
606 f: glib_sys::gpointer,
607 ) -> glib_sys::gboolean
608 where
609 P: IsA<EntryCompletion>,
610 {
611 let f: &F = &*(f as *const F);
612 f(
613 &EntryCompletion::from_glib_borrow(this).unsafe_cast(),
614 &from_glib_borrow(model),
615 &from_glib_borrow(iter),
616 )
617 .to_glib()
618 }
619 unsafe {
620 let f: Box_<F> = Box_::new(f);
621 connect_raw(
622 self.as_ptr() as *mut _,
623 b"match-selected\0".as_ptr() as *const _,
624 Some(transmute(match_selected_trampoline::<Self, F> as usize)),
625 Box_::into_raw(f),
626 )
627 }
628 }
629
630 fn connect_no_matches<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
631 unsafe extern "C" fn no_matches_trampoline<P, F: Fn(&P) + 'static>(
632 this: *mut gtk_sys::GtkEntryCompletion,
633 f: glib_sys::gpointer,
634 ) where
635 P: IsA<EntryCompletion>,
636 {
637 let f: &F = &*(f as *const F);
638 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
639 }
640 unsafe {
641 let f: Box_<F> = Box_::new(f);
642 connect_raw(
643 self.as_ptr() as *mut _,
644 b"no-matches\0".as_ptr() as *const _,
645 Some(transmute(no_matches_trampoline::<Self, F> as usize)),
646 Box_::into_raw(f),
647 )
648 }
649 }
650
651 fn connect_property_inline_completion_notify<F: Fn(&Self) + 'static>(
652 &self,
653 f: F,
654 ) -> SignalHandlerId {
655 unsafe extern "C" fn notify_inline_completion_trampoline<P, F: Fn(&P) + 'static>(
656 this: *mut gtk_sys::GtkEntryCompletion,
657 _param_spec: glib_sys::gpointer,
658 f: glib_sys::gpointer,
659 ) where
660 P: IsA<EntryCompletion>,
661 {
662 let f: &F = &*(f as *const F);
663 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
664 }
665 unsafe {
666 let f: Box_<F> = Box_::new(f);
667 connect_raw(
668 self.as_ptr() as *mut _,
669 b"notify::inline-completion\0".as_ptr() as *const _,
670 Some(transmute(
671 notify_inline_completion_trampoline::<Self, F> as usize,
672 )),
673 Box_::into_raw(f),
674 )
675 }
676 }
677
678 fn connect_property_inline_selection_notify<F: Fn(&Self) + 'static>(
679 &self,
680 f: F,
681 ) -> SignalHandlerId {
682 unsafe extern "C" fn notify_inline_selection_trampoline<P, F: Fn(&P) + 'static>(
683 this: *mut gtk_sys::GtkEntryCompletion,
684 _param_spec: glib_sys::gpointer,
685 f: glib_sys::gpointer,
686 ) where
687 P: IsA<EntryCompletion>,
688 {
689 let f: &F = &*(f as *const F);
690 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
691 }
692 unsafe {
693 let f: Box_<F> = Box_::new(f);
694 connect_raw(
695 self.as_ptr() as *mut _,
696 b"notify::inline-selection\0".as_ptr() as *const _,
697 Some(transmute(
698 notify_inline_selection_trampoline::<Self, F> as usize,
699 )),
700 Box_::into_raw(f),
701 )
702 }
703 }
704
705 fn connect_property_minimum_key_length_notify<F: Fn(&Self) + 'static>(
706 &self,
707 f: F,
708 ) -> SignalHandlerId {
709 unsafe extern "C" fn notify_minimum_key_length_trampoline<P, F: Fn(&P) + 'static>(
710 this: *mut gtk_sys::GtkEntryCompletion,
711 _param_spec: glib_sys::gpointer,
712 f: glib_sys::gpointer,
713 ) where
714 P: IsA<EntryCompletion>,
715 {
716 let f: &F = &*(f as *const F);
717 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
718 }
719 unsafe {
720 let f: Box_<F> = Box_::new(f);
721 connect_raw(
722 self.as_ptr() as *mut _,
723 b"notify::minimum-key-length\0".as_ptr() as *const _,
724 Some(transmute(
725 notify_minimum_key_length_trampoline::<Self, F> as usize,
726 )),
727 Box_::into_raw(f),
728 )
729 }
730 }
731
732 fn connect_property_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
733 unsafe extern "C" fn notify_model_trampoline<P, F: Fn(&P) + 'static>(
734 this: *mut gtk_sys::GtkEntryCompletion,
735 _param_spec: glib_sys::gpointer,
736 f: glib_sys::gpointer,
737 ) where
738 P: IsA<EntryCompletion>,
739 {
740 let f: &F = &*(f as *const F);
741 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
742 }
743 unsafe {
744 let f: Box_<F> = Box_::new(f);
745 connect_raw(
746 self.as_ptr() as *mut _,
747 b"notify::model\0".as_ptr() as *const _,
748 Some(transmute(notify_model_trampoline::<Self, F> as usize)),
749 Box_::into_raw(f),
750 )
751 }
752 }
753
754 fn connect_property_popup_completion_notify<F: Fn(&Self) + 'static>(
755 &self,
756 f: F,
757 ) -> SignalHandlerId {
758 unsafe extern "C" fn notify_popup_completion_trampoline<P, F: Fn(&P) + 'static>(
759 this: *mut gtk_sys::GtkEntryCompletion,
760 _param_spec: glib_sys::gpointer,
761 f: glib_sys::gpointer,
762 ) where
763 P: IsA<EntryCompletion>,
764 {
765 let f: &F = &*(f as *const F);
766 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
767 }
768 unsafe {
769 let f: Box_<F> = Box_::new(f);
770 connect_raw(
771 self.as_ptr() as *mut _,
772 b"notify::popup-completion\0".as_ptr() as *const _,
773 Some(transmute(
774 notify_popup_completion_trampoline::<Self, F> as usize,
775 )),
776 Box_::into_raw(f),
777 )
778 }
779 }
780
781 fn connect_property_popup_set_width_notify<F: Fn(&Self) + 'static>(
782 &self,
783 f: F,
784 ) -> SignalHandlerId {
785 unsafe extern "C" fn notify_popup_set_width_trampoline<P, F: Fn(&P) + 'static>(
786 this: *mut gtk_sys::GtkEntryCompletion,
787 _param_spec: glib_sys::gpointer,
788 f: glib_sys::gpointer,
789 ) where
790 P: IsA<EntryCompletion>,
791 {
792 let f: &F = &*(f as *const F);
793 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
794 }
795 unsafe {
796 let f: Box_<F> = Box_::new(f);
797 connect_raw(
798 self.as_ptr() as *mut _,
799 b"notify::popup-set-width\0".as_ptr() as *const _,
800 Some(transmute(
801 notify_popup_set_width_trampoline::<Self, F> as usize,
802 )),
803 Box_::into_raw(f),
804 )
805 }
806 }
807
808 fn connect_property_popup_single_match_notify<F: Fn(&Self) + 'static>(
809 &self,
810 f: F,
811 ) -> SignalHandlerId {
812 unsafe extern "C" fn notify_popup_single_match_trampoline<P, F: Fn(&P) + 'static>(
813 this: *mut gtk_sys::GtkEntryCompletion,
814 _param_spec: glib_sys::gpointer,
815 f: glib_sys::gpointer,
816 ) where
817 P: IsA<EntryCompletion>,
818 {
819 let f: &F = &*(f as *const F);
820 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
821 }
822 unsafe {
823 let f: Box_<F> = Box_::new(f);
824 connect_raw(
825 self.as_ptr() as *mut _,
826 b"notify::popup-single-match\0".as_ptr() as *const _,
827 Some(transmute(
828 notify_popup_single_match_trampoline::<Self, F> as usize,
829 )),
830 Box_::into_raw(f),
831 )
832 }
833 }
834
835 fn connect_property_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
836 unsafe extern "C" fn notify_text_column_trampoline<P, F: Fn(&P) + 'static>(
837 this: *mut gtk_sys::GtkEntryCompletion,
838 _param_spec: glib_sys::gpointer,
839 f: glib_sys::gpointer,
840 ) where
841 P: IsA<EntryCompletion>,
842 {
843 let f: &F = &*(f as *const F);
844 f(&EntryCompletion::from_glib_borrow(this).unsafe_cast())
845 }
846 unsafe {
847 let f: Box_<F> = Box_::new(f);
848 connect_raw(
849 self.as_ptr() as *mut _,
850 b"notify::text-column\0".as_ptr() as *const _,
851 Some(transmute(notify_text_column_trampoline::<Self, F> as usize)),
852 Box_::into_raw(f),
853 )
854 }
855 }
856}
857
858impl fmt::Display for EntryCompletion {
859 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
860 write!(f, "EntryCompletion")
861 }
862}