fingerprint add ui mockup

This commit is contained in:
Ferdinand Schober
2024-09-27 12:05:34 +02:00
parent f056f790c7
commit 0038178f0d
14 changed files with 478 additions and 234 deletions

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="FingerprintWindow" parent="AdwWindow">
<property name="modal">True</property>
<property name="width-request">880</property>
<property name="default-width">880</property>
<property name="default-height">240</property>
<property name="title" translatable="yes">Add Public Key Fingerprint</property>
<property name="content">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar"/>
</child>
<property name="content">
<object class="AdwClamp">
<property name="maximum-size">770</property>
<property name="tightening-threshold">0</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">fingerprint</property>
<property name="child">
<object class="GtkText" id="text">
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="enable-undo">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="max-length">0</property>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="halign">center</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Confirm</property>
<property name="can-shrink">True</property>
<style>
<class name="pill"/>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</property>
</object>
</property>
</template>
</interface>

View File

@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/de/feschber/LanMouse">
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">fingerprint_window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">client_row.ui</file>
</gresource>
<gresource prefix="/de/feschber/LanMouse/icons">

View 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
}
}

View 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 {}

View File

@@ -1,5 +1,6 @@
mod client_object;
mod client_row;
mod fingerprint_window;
mod window;
use std::{env, process, str};

View File

@@ -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();

View File

@@ -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) {