mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-09 22:31:28 +03:00
fingerprint add ui mockup
This commit is contained in:
24
lan-mouse-gtk/src/fingerprint_window.rs
Normal file
24
lan-mouse-gtk/src/fingerprint_window.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
mod imp;
|
||||
|
||||
use adw::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::{clone, Object};
|
||||
use gtk::{
|
||||
gio,
|
||||
glib::{self, closure_local},
|
||||
ListBox, NoSelection,
|
||||
};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct FingerprintWindow(ObjectSubclass<imp::FingerprintWindow>)
|
||||
@extends adw::Window, gtk::Window, gtk::Widget,
|
||||
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
|
||||
gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
|
||||
}
|
||||
|
||||
impl FingerprintWindow {
|
||||
pub(crate) fn new() -> Self {
|
||||
let window: Self = Object::builder().build();
|
||||
window
|
||||
}
|
||||
}
|
||||
45
lan-mouse-gtk/src/fingerprint_window/imp.rs
Normal file
45
lan-mouse-gtk/src/fingerprint_window/imp.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::subclass::InitializingObject;
|
||||
use gtk::{glib, template_callbacks, CompositeTemplate, Entry};
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/de/feschber/LanMouse/fingerprint_window.ui")]
|
||||
pub struct FingerprintWindow {
|
||||
// #[template_child]
|
||||
// pub fingerprint_entry: TemplateChild<Entry>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for FingerprintWindow {
|
||||
const NAME: &'static str = "FingerprintWindow";
|
||||
const ABSTRACT: bool = false;
|
||||
|
||||
type Type = super::FingerprintWindow;
|
||||
type ParentType = adw::Window;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
klass.bind_template_callbacks();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
#[template_callbacks]
|
||||
impl FingerprintWindow {
|
||||
// #[template_callback]
|
||||
// fn handle_confirm() {}
|
||||
}
|
||||
|
||||
impl ObjectImpl for FingerprintWindow {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for FingerprintWindow {}
|
||||
impl WindowImpl for FingerprintWindow {}
|
||||
impl ApplicationWindowImpl for FingerprintWindow {}
|
||||
impl AdwWindowImpl for FingerprintWindow {}
|
||||
@@ -1,5 +1,6 @@
|
||||
mod client_object;
|
||||
mod client_row;
|
||||
mod fingerprint_window;
|
||||
mod window;
|
||||
|
||||
use std::{env, process, str};
|
||||
|
||||
@@ -6,7 +6,7 @@ use glib::{clone, Object};
|
||||
use gtk::{
|
||||
gio,
|
||||
glib::{self, closure_local},
|
||||
ListBox, NoSelection,
|
||||
ListBox, NoSelection, Widget,
|
||||
};
|
||||
|
||||
use lan_mouse_ipc::{
|
||||
@@ -14,6 +14,8 @@ use lan_mouse_ipc::{
|
||||
DEFAULT_PORT,
|
||||
};
|
||||
|
||||
use crate::fingerprint_window::FingerprintWindow;
|
||||
|
||||
use super::{client_object::ClientObject, client_row::ClientRow};
|
||||
|
||||
glib::wrapper! {
|
||||
@@ -286,6 +288,16 @@ impl Window {
|
||||
self.request(FrontendRequest::Delete(client.handle()));
|
||||
}
|
||||
|
||||
pub fn open_fingerprint_dialog(&self) {
|
||||
let window = FingerprintWindow::new();
|
||||
window.set_transient_for(Some(self));
|
||||
window.present();
|
||||
}
|
||||
|
||||
pub fn request_fingerprint_add(&self, fp: String) {
|
||||
self.request(FrontendRequest::FingerprintAdd(fp));
|
||||
}
|
||||
|
||||
pub fn request(&self, request: FrontendRequest) {
|
||||
let mut requester = self.imp().frontend_request_writer.borrow_mut();
|
||||
let requester = requester.as_mut().unwrap();
|
||||
|
||||
@@ -120,7 +120,7 @@ impl Window {
|
||||
|
||||
#[template_callback]
|
||||
fn handle_add_cert_fingerprint(&self, _button: &Button) {
|
||||
log::info!("TODO: impl add certificate fingerprint");
|
||||
self.obj().open_fingerprint_dialog();
|
||||
}
|
||||
|
||||
pub fn set_port(&self, port: u16) {
|
||||
|
||||
Reference in New Issue
Block a user