Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
install_data(
'xyz.iinuwa.credentialsd.Credentials.xml',
install_dir: datadir / 'credentialsd',
)
32 changes: 10 additions & 22 deletions credentialsd-ui/data/resources/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,11 @@
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">win.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About Credential Manager</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
<template class="ExampleApplicationWindow" parent="GtkApplicationWindow">
<template class="CredentialsUiWindow" parent="GtkApplicationWindow">
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<child type="end">
<object class="GtkMenuButton" id="appmenu_button">
<property name="icon-name">open-menu-symbolic</property>
<property name="menu-model">primary_menu</property>
<property name="primary">True</property>
<property name="tooltip-text" translatable="yes">Main Menu</property>
</object>
</child>
</object>
</child>
<child>
Expand All @@ -37,7 +25,7 @@
<binding name="label">
<lookup name="title">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand Down Expand Up @@ -67,7 +55,7 @@
<binding name="child">
<lookup name="devices">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand Down Expand Up @@ -95,7 +83,7 @@
<binding name="label">
<lookup name="prompt">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand All @@ -107,7 +95,7 @@
<binding name="visible">
<lookup name="usb_pin_entry_visible">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand All @@ -131,7 +119,7 @@
<binding name="visible">
<lookup name="qr_spinner_visible">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand All @@ -142,7 +130,7 @@
<binding name="visible">
<lookup name="qr_code_visible">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand All @@ -153,7 +141,7 @@
<binding name="label">
<lookup name="prompt">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand Down Expand Up @@ -182,7 +170,7 @@
<binding name="child">
<lookup name="credentials">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand Down Expand Up @@ -222,7 +210,7 @@
<binding name="label">
<lookup name="prompt">
<lookup name="view-model">
ExampleApplicationWindow
CredentialsUiWindow
</lookup>
</lookup>
</binding>
Expand Down
54 changes: 16 additions & 38 deletions credentialsd-ui/src/gui/view_model/gtk/application.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use async_std::channel::{Receiver, Sender};
use gettextrs::gettext;
use tracing::{debug, info};

use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gdk, gio, glib};

use super::{ViewModel, window::ExampleApplicationWindow};
use super::{ViewModel, window::CredentialsUiWindow};
use crate::config::{APP_ID, PKGDATADIR, PROFILE, VERSION};
use crate::gui::view_model::{ViewEvent, ViewUpdate};

Expand All @@ -21,25 +20,25 @@ mod imp {
};

#[derive(Debug, Default)]
pub struct ExampleApplication {
pub window: OnceCell<WeakRef<ExampleApplicationWindow>>,
pub struct CredentialsUi {
pub window: OnceCell<WeakRef<CredentialsUiWindow>>,

pub(super) tx: RefCell<Option<Sender<ViewEvent>>>,
pub(super) rx: RefCell<Option<Receiver<ViewUpdate>>>,
}

#[glib::object_subclass]
impl ObjectSubclass for ExampleApplication {
const NAME: &'static str = "ExampleApplication";
type Type = super::ExampleApplication;
impl ObjectSubclass for CredentialsUi {
const NAME: &'static str = "CredentialsUi";
type Type = super::CredentialsUi;
type ParentType = gtk::Application;
}

impl ObjectImpl for ExampleApplication {}
impl ObjectImpl for CredentialsUi {}

impl ApplicationImpl for ExampleApplication {
impl ApplicationImpl for CredentialsUi {
fn activate(&self) {
debug!("GtkApplication<ExampleApplication>::activate");
debug!("GtkApplication<CredentialsUi>::activate");
self.parent_activate();
let app = self.obj();

Expand All @@ -53,7 +52,7 @@ mod imp {
let rx = self.rx.take().expect("receiver to be initiated");
let view_model = ViewModel::new(tx, rx);
let vm2 = view_model.clone();
let window = ExampleApplicationWindow::new(&app, view_model);
let window = CredentialsUiWindow::new(&app, view_model);
let window2 = window.clone();
vm2.clone().connect_completed_notify(move |vm| {
if vm.completed() {
Expand Down Expand Up @@ -91,7 +90,7 @@ mod imp {
}

fn startup(&self) {
debug!("GtkApplication<ExampleApplication>::startup");
debug!("GtkApplication<CredentialsUi>::startup");
self.parent_startup();
let app = self.obj();

Expand All @@ -104,17 +103,17 @@ mod imp {
}
}

impl GtkApplicationImpl for ExampleApplication {}
impl GtkApplicationImpl for CredentialsUi {}
}

glib::wrapper! {
pub struct ExampleApplication(ObjectSubclass<imp::ExampleApplication>)
pub struct CredentialsUi(ObjectSubclass<imp::CredentialsUi>)
@extends gio::Application, gtk::Application,
@implements gio::ActionMap, gio::ActionGroup;
}

impl ExampleApplication {
fn main_window(&self) -> ExampleApplicationWindow {
impl CredentialsUi {
fn main_window(&self) -> CredentialsUiWindow {
self.imp().window.get().unwrap().upgrade().unwrap()
}

Expand All @@ -128,13 +127,7 @@ impl ExampleApplication {
})
.build();

// About
let action_about = gio::ActionEntry::builder("about")
.activate(|app: &Self, _, _| {
app.show_about_dialog();
})
.build();
self.add_action_entries([action_quit, action_about]);
self.add_action_entries([action_quit]);
}

// Sets up keyboard shortcuts
Expand All @@ -155,21 +148,6 @@ impl ExampleApplication {
}
}

fn show_about_dialog(&self) {
let dialog = gtk::AboutDialog::builder()
.logo_icon_name(APP_ID)
.license_type(gtk::License::Lgpl30Only)
.website("https://github.com/linux-credentials/linux-webauthn-portal-api")
.version(VERSION)
.transient_for(&self.main_window())
.translator_credits(gettext("translator-credits"))
.modal(true)
.authors(vec!["Isaiah Inuwa <isaiah.inuwa@gmail.com>"])
.build();

dialog.present();
}

pub fn run(&self) -> glib::ExitCode {
info!("Credentials UI ({})", APP_ID);
info!("Version: {} ({})", VERSION, PROFILE);
Expand Down
4 changes: 2 additions & 2 deletions credentialsd-ui/src/gui/view_model/gtk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use qrcode::QrCode;
use tracing::debug;

use crate::config::{GETTEXT_PACKAGE, LOCALEDIR, RESOURCES_FILE};
use application::ExampleApplication;
use application::CredentialsUi;

use super::Transport;
use super::{Credential, Device};
Expand Down Expand Up @@ -365,7 +365,7 @@ pub fn start_gtk_app(
let res = gio::Resource::load(RESOURCES_FILE).expect("Could not load gresource file");
gio::resources_register(&res);

let app = ExampleApplication::new(tx_event, rx_update);
let app = CredentialsUi::new(tx_event, rx_update);
app.run();
}

Expand Down
32 changes: 16 additions & 16 deletions credentialsd-ui/src/gui/view_model/gtk/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use gtk::{
glib::{self, clone},
};

use super::application::ExampleApplication;
use super::application::CredentialsUi;
use super::{ViewModel, device::DeviceObject};
use crate::config::{APP_ID, PROFILE};
use crate::gui::view_model::Transport;
Expand All @@ -22,9 +22,9 @@ mod imp {
use super::*;

#[derive(Debug, Properties, gtk::CompositeTemplate)]
#[properties(wrapper_type = super::ExampleApplicationWindow)]
#[properties(wrapper_type = super::CredentialsUiWindow)]
#[template(resource = "/xyz/iinuwa/credentialsd/CredentialsUi/ui/window.ui")]
pub struct ExampleApplicationWindow {
pub struct CredentialsUiWindow {
#[template_child]
pub headerbar: TemplateChild<gtk::HeaderBar>,
pub settings: gio::Settings,
Expand All @@ -42,7 +42,7 @@ mod imp {
}

#[gtk::template_callbacks]
impl ExampleApplicationWindow {
impl CredentialsUiWindow {
#[template_callback]
fn handle_usb_pin_entered(&self, entry: &gtk::PasswordEntry) {
let view_model = &self.view_model.borrow();
Expand All @@ -58,7 +58,7 @@ mod imp {
}
}

impl Default for ExampleApplicationWindow {
impl Default for CredentialsUiWindow {
fn default() -> Self {
Self {
headerbar: TemplateChild::default(),
Expand All @@ -72,9 +72,9 @@ mod imp {
}

#[glib::object_subclass]
impl ObjectSubclass for ExampleApplicationWindow {
const NAME: &'static str = "ExampleApplicationWindow";
type Type = super::ExampleApplicationWindow;
impl ObjectSubclass for CredentialsUiWindow {
const NAME: &'static str = "CredentialsUiWindow";
type Type = super::CredentialsUiWindow;
type ParentType = gtk::ApplicationWindow;

fn class_init(klass: &mut Self::Class) {
Expand All @@ -89,7 +89,7 @@ mod imp {
}

#[glib::derived_properties]
impl ObjectImpl for ExampleApplicationWindow {
impl ObjectImpl for CredentialsUiWindow {
fn constructed(&self) {
self.parent_constructed();
let obj = self.obj();
Expand All @@ -104,8 +104,8 @@ mod imp {
}
}

impl WidgetImpl for ExampleApplicationWindow {}
impl WindowImpl for ExampleApplicationWindow {
impl WidgetImpl for CredentialsUiWindow {}
impl WindowImpl for CredentialsUiWindow {
// Save window state on delete event
fn close_request(&self) -> glib::Propagation {
if let Some(vm) = self.view_model.borrow().as_ref() {
Expand All @@ -128,19 +128,19 @@ mod imp {
}
}

impl ApplicationWindowImpl for ExampleApplicationWindow {}
impl ApplicationWindowImpl for CredentialsUiWindow {}
}

glib::wrapper! {
pub struct ExampleApplicationWindow(ObjectSubclass<imp::ExampleApplicationWindow>)
pub struct CredentialsUiWindow(ObjectSubclass<imp::CredentialsUiWindow>)
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow,
@implements gio::ActionMap, gio::ActionGroup, gtk::Root;

}

impl ExampleApplicationWindow {
pub fn new(app: &ExampleApplication, view_model: ViewModel) -> Self {
let window: ExampleApplicationWindow = glib::Object::builder()
impl CredentialsUiWindow {
pub fn new(app: &CredentialsUi, view_model: ViewModel) -> Self {
let window: CredentialsUiWindow = glib::Object::builder()
.property("application", app)
.property("view-model", view_model)
.build();
Expand Down
5 changes: 4 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ version = meson.project_version()

prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
libdir = prefix / get_option('libdir')
localedir = prefix / get_option('localedir')

cargo_home = get_option('cargo_home')
Expand All @@ -29,4 +30,6 @@ subdir('credentialsd-common')
subdir('credentialsd')
subdir('credentialsd-ui')
subdir('dbus')
subdir('systemd')
subdir('systemd')
subdir('webext')
subdir('contrib')
2 changes: 1 addition & 1 deletion systemd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ configure_file(
install_dir: systemd_user_service_dir,
output: 'xyz.iinuwa.credentialsd.UiControl.service',
configuration: systemd_config,
)
)
Loading