50 lines
1.4 KiB
Rust
50 lines
1.4 KiB
Rust
|
use adw::{prelude::*, subclass::prelude::*};
|
||
|
use glib::Object;
|
||
|
use kifu_core::ui::ConfigurationView;
|
||
|
|
||
|
#[derive(Default)]
|
||
|
pub struct ConfigurationPagePrivate {}
|
||
|
|
||
|
#[glib::object_subclass]
|
||
|
impl ObjectSubclass for ConfigurationPagePrivate {
|
||
|
const NAME: &'static str = "Configuration";
|
||
|
type Type = ConfigurationPage;
|
||
|
type ParentType = adw::PreferencesPage;
|
||
|
}
|
||
|
|
||
|
impl ObjectImpl for ConfigurationPagePrivate {}
|
||
|
impl WidgetImpl for ConfigurationPagePrivate {}
|
||
|
impl PreferencesPageImpl for ConfigurationPagePrivate {}
|
||
|
|
||
|
glib::wrapper! {
|
||
|
pub struct ConfigurationPage(ObjectSubclass<ConfigurationPagePrivate>)
|
||
|
@extends adw::PreferencesPage, gtk::Widget,
|
||
|
@implements gtk::Orientable;
|
||
|
}
|
||
|
|
||
|
impl ConfigurationPage {
|
||
|
pub fn new(view: ConfigurationView) -> Self {
|
||
|
let s: Self = Object::builder().build();
|
||
|
|
||
|
let group = adw::PreferencesGroup::builder().build();
|
||
|
|
||
|
let library_entry = &adw::EntryRow::builder()
|
||
|
.name("library-path")
|
||
|
.title(view.library.label)
|
||
|
.show_apply_button(true)
|
||
|
.build();
|
||
|
if let Some(path) = view.library.value {
|
||
|
library_entry.set_text(&path);
|
||
|
}
|
||
|
library_entry.connect_apply(|entry| {
|
||
|
println!("Set the library path to {}", entry.text());
|
||
|
});
|
||
|
|
||
|
group.add(library_entry);
|
||
|
|
||
|
s.add(&group);
|
||
|
|
||
|
s
|
||
|
}
|
||
|
}
|