1+ mod application;
12pub mod credential;
23pub mod device;
4+ mod window;
35
46use async_std:: channel:: { Receiver , Sender } ;
7+ use gettextrs:: { gettext, LocaleCategory } ;
58use glib:: clone;
69use gtk:: gdk:: Texture ;
710use gtk:: gdk_pixbuf:: Pixbuf ;
@@ -12,13 +15,16 @@ use gtk::subclass::prelude::*;
1215use qrcode:: QrCode ;
1316use tracing:: debug;
1417
15- use self :: credential :: CredentialObject ;
16- use self :: device :: DeviceObject ;
18+ use crate :: config :: { GETTEXT_PACKAGE , LOCALEDIR , RESOURCES_FILE } ;
19+ use application :: ExampleApplication ;
1720
1821use super :: Transport ;
1922use super :: { Credential , Device } ;
2023use super :: { ViewEvent , ViewUpdate } ;
2124
25+ use self :: credential:: CredentialObject ;
26+ use self :: device:: DeviceObject ;
27+
2228mod imp {
2329 use std:: cell:: RefCell ;
2430
@@ -51,7 +57,7 @@ mod imp {
5157 #[ property( get, set) ]
5258 pub failed : RefCell < bool > ,
5359
54- // pub(super) vm: RefCell<Option<crate::view_model::ViewModel>>,
60+ // pub(super) vm: RefCell<Option<crate::gui:: view_model::ViewModel>>,
5561 pub ( super ) rx : RefCell < Option < Receiver < ViewUpdate > > > ,
5662 pub ( super ) tx : RefCell < Option < Sender < ViewEvent > > > ,
5763 // hybrid_qr_state: HybridState,
@@ -337,3 +343,22 @@ impl ViewModel {
337343 tx. send ( event) . await . unwrap ( ) ;
338344 }
339345}
346+
347+ pub fn start_gtk_app (
348+ tx_event : async_std:: channel:: Sender < ViewEvent > ,
349+ rx_update : async_std:: channel:: Receiver < ViewUpdate > ,
350+ ) {
351+ // Prepare i18n
352+ gettextrs:: setlocale ( LocaleCategory :: LcAll , "" ) ;
353+ gettextrs:: bindtextdomain ( GETTEXT_PACKAGE , LOCALEDIR ) . expect ( "Unable to bind the text domain" ) ;
354+ gettextrs:: textdomain ( GETTEXT_PACKAGE ) . expect ( "Unable to switch to the text domain" ) ;
355+
356+ if glib:: application_name ( ) . is_none ( ) {
357+ glib:: set_application_name ( & gettext ( "Credential Manager" ) ) ;
358+ }
359+ let res = gio:: Resource :: load ( RESOURCES_FILE ) . expect ( "Could not load gresource file" ) ;
360+ gio:: resources_register ( & res) ;
361+
362+ let app = ExampleApplication :: new ( tx_event, rx_update) ;
363+ app. run ( ) ;
364+ }
0 commit comments