App: don't allow App::new() to fail
This commit is contained in:
parent
4f6d546830
commit
0ce3e63e33
1 changed files with 4 additions and 14 deletions
|
@ -3,7 +3,6 @@ use gio::prelude::*;
|
||||||
use gtk;
|
use gtk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::error::Error;
|
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
|
@ -13,8 +12,6 @@ use std::sync::{Arc, Mutex, Weak as SyncWeak};
|
||||||
use appop::AppOp;
|
use appop::AppOp;
|
||||||
use backend::BKResponse;
|
use backend::BKResponse;
|
||||||
use backend::Backend;
|
use backend::Backend;
|
||||||
use i18n::i18n;
|
|
||||||
use widgets::ErrorDialog;
|
|
||||||
|
|
||||||
use actions;
|
use actions;
|
||||||
use globals;
|
use globals;
|
||||||
|
@ -76,7 +73,7 @@ impl AppWeak {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(gtk_app: >k::Application) -> Result<App, Box<dyn Error>> {
|
pub fn new(gtk_app: >k::Application) -> App {
|
||||||
let (tx, rx): (Sender<BKResponse>, Receiver<BKResponse>) = channel();
|
let (tx, rx): (Sender<BKResponse>, Receiver<BKResponse>) = channel();
|
||||||
|
|
||||||
let bk = Backend::new(tx);
|
let bk = Backend::new(tx);
|
||||||
|
@ -151,7 +148,7 @@ impl App {
|
||||||
|
|
||||||
app.connect_gtk();
|
app.connect_gtk();
|
||||||
|
|
||||||
Ok(app)
|
app
|
||||||
}
|
}
|
||||||
|
|
||||||
// Downgrade to a weak reference
|
// Downgrade to a weak reference
|
||||||
|
@ -160,15 +157,8 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_startup(gtk_app: >k::Application) {
|
pub fn on_startup(gtk_app: >k::Application) {
|
||||||
// Create application and error out if that fails for whatever reason
|
// Create application
|
||||||
let app = match App::new(gtk_app) {
|
let app = App::new(gtk_app);
|
||||||
Ok(app) => app,
|
|
||||||
Err(err) => {
|
|
||||||
let msg = format!("{} {}", i18n("Error creating application:"), err);
|
|
||||||
ErrorDialog::new(true, &msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let app_weak = app.downgrade();
|
let app_weak = app.downgrade();
|
||||||
gtk_app.connect_activate(move |_| {
|
gtk_app.connect_activate(move |_| {
|
||||||
|
|
Loading…
Reference in a new issue