Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Improve get_entry method
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed May 28, 2019
1 parent 178eece commit b8f1942
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ status = "generate"

[[object]]
name = "Gtk.EntryCompletion"
manual_traits = ["EntryCompletionExtManual"]
status = "generate"
[[object.signal]]
name = "insert-prefix"
Expand All @@ -963,6 +964,9 @@ status = "generate"
[[object.signal]]
name = "cursor-on-match"
inhibit = true
[[object.function]]
name = "get_entry"
ignore = true

[[object]]
name = "Gtk.Expander"
Expand Down
27 changes: 27 additions & 0 deletions src/entry_completion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2019, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use glib::Cast;
use glib::object::IsA;
use glib::translate::*;
use gtk_sys;
use Entry;
use EntryCompletion;
use Widget;

pub trait EntryCompletionExtManual: 'static {
fn get_entry(&self) -> Option<Entry>;
}

impl<O: IsA<EntryCompletion>> EntryCompletionExtManual for O {
fn get_entry(&self) -> Option<Entry> {
let widget: Option<Widget> = unsafe {
from_glib_none(gtk_sys::gtk_entry_completion_get_entry(self.as_ref().to_glib_none().0))
};
match widget {
Some(w) => w.downcast().ok(),
None => None,
}
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ mod combo_box;
mod dialog;
mod drag_context;
mod entry_buffer;
mod entry_completion;
mod enums;
mod file_chooser_dialog;
mod fixed;
Expand Down
1 change: 1 addition & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub use color_chooser::ColorChooserExtManual;
pub use combo_box::ComboBoxExtManual;
pub use dialog::DialogExtManual;
pub use drag_context::DragContextExtManual;
pub use entry_completion::EntryCompletionExtManual;
pub use fixed::FixedExtManual;
#[cfg(any(feature = "v3_18", feature = "dox"))]
pub use flow_box::FlowBoxExtManual;
Expand Down

0 comments on commit b8f1942

Please sign in to comment.