components: Add CustomEntry
This commit is contained in:
parent
0deb8457b0
commit
97560a3efd
4 changed files with 50 additions and 0 deletions
|
@ -34,6 +34,7 @@ data/resources/ui/window.ui
|
|||
src/application.rs
|
||||
src/components/avatar.rs
|
||||
src/components/context_menu_bin.rs
|
||||
src/components/custom_entry.rs
|
||||
src/components/label_with_widgets.rs
|
||||
src/components/in_app_notification.rs
|
||||
src/components/mod.rs
|
||||
|
|
46
src/components/custom_entry.rs
Normal file
46
src/components/custom_entry.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use adw::subclass::prelude::*;
|
||||
use gtk::glib;
|
||||
use gtk::subclass::prelude::*;
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CustomEntry {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for CustomEntry {
|
||||
const NAME: &'static str = "CustomEntry";
|
||||
type Type = super::CustomEntry;
|
||||
type ParentType = adw::Bin;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.set_css_name("entry");
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for CustomEntry {}
|
||||
impl WidgetImpl for CustomEntry {}
|
||||
impl BinImpl for CustomEntry {}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
/// Wrapper object acting as an entry.
|
||||
///
|
||||
/// Wrap your custom widgets with CustomEntry to get stock entry styling and
|
||||
/// behavior for free.
|
||||
pub struct CustomEntry(ObjectSubclass<imp::CustomEntry>)
|
||||
@extends gtk::Widget, adw::Bin;
|
||||
}
|
||||
|
||||
impl CustomEntry {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new(&[]).expect("Failed to create CustomEntry")
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CustomEntry {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
mod avatar;
|
||||
mod context_menu_bin;
|
||||
mod custom_entry;
|
||||
mod in_app_notification;
|
||||
mod label_with_widgets;
|
||||
mod pill;
|
||||
|
@ -8,6 +9,7 @@ mod spinner_button;
|
|||
|
||||
pub use self::avatar::Avatar;
|
||||
pub use self::context_menu_bin::{ContextMenuBin, ContextMenuBinExt, ContextMenuBinImpl};
|
||||
pub use self::custom_entry::CustomEntry;
|
||||
pub use self::in_app_notification::InAppNotification;
|
||||
pub use self::label_with_widgets::LabelWithWidgets;
|
||||
pub use self::pill::Pill;
|
||||
|
|
|
@ -22,6 +22,7 @@ sources = files(
|
|||
'application.rs',
|
||||
'components/avatar.rs',
|
||||
'components/context_menu_bin.rs',
|
||||
'components/custom_entry.rs',
|
||||
'components/label_with_widgets.rs',
|
||||
'components/mod.rs',
|
||||
'components/pill.rs',
|
||||
|
|
Loading…
Reference in a new issue