gtk/
entry_completion.rs

1// Copyright 2019, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use glib::object::IsA;
6use glib::translate::*;
7use glib::Cast;
8use gtk_sys;
9use Entry;
10use EntryCompletion;
11use Widget;
12
13pub trait EntryCompletionExtManual: 'static {
14    fn get_entry(&self) -> Option<Entry>;
15}
16
17impl<O: IsA<EntryCompletion>> EntryCompletionExtManual for O {
18    fn get_entry(&self) -> Option<Entry> {
19        unsafe {
20            Option::<Widget>::from_glib_none(gtk_sys::gtk_entry_completion_get_entry(
21                self.as_ref().to_glib_none().0,
22            ))
23            .map(|widget| {
24                widget
25                    .downcast()
26                    .expect("Non-Entry widget received from get_entry method")
27            })
28        }
29    }
30}