mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-11 02:44:15 +00:00
implement profile directory open
This commit is contained in:
parent
82219c01b9
commit
a83b28bcc1
@ -13,7 +13,7 @@ use gtk::{
|
|||||||
};
|
};
|
||||||
use sqlite::Connection;
|
use sqlite::Connection;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
const APPLICATION_ID: &str = "io.github.yggverse.Yoda";
|
const APPLICATION_ID: &str = "io.github.yggverse.Yoda";
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ pub struct App {
|
|||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(profile_database_connection: Arc<Connection>) -> Self {
|
pub fn new(profile_database_connection: Arc<Connection>, profile_path: PathBuf) -> Self {
|
||||||
// Init database model
|
// Init database model
|
||||||
let database = match Database::init(profile_database_connection) {
|
let database = match Database::init(profile_database_connection) {
|
||||||
Ok(database) => Arc::new(database),
|
Ok(database) => Arc::new(database),
|
||||||
@ -83,6 +83,7 @@ impl App {
|
|||||||
// Init components
|
// Init components
|
||||||
let browser = Arc::new(Browser::new(
|
let browser = Arc::new(Browser::new(
|
||||||
/*db.clone(),*/
|
/*db.clone(),*/
|
||||||
|
profile_path,
|
||||||
action_tool_debug.simple(),
|
action_tool_debug.simple(),
|
||||||
action_tool_profile_directory.simple(),
|
action_tool_profile_directory.simple(),
|
||||||
action_quit.simple(),
|
action_quit.simple(),
|
||||||
|
@ -5,11 +5,11 @@ use header::Header;
|
|||||||
use main::Main;
|
use main::Main;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::{AppInfo, AppLaunchContext, SimpleAction},
|
||||||
prelude::{ActionMapExt, GtkWindowExt},
|
prelude::{ActionMapExt, GtkWindowExt},
|
||||||
ApplicationWindow,
|
ApplicationWindow,
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
const DEFAULT_HEIGHT: i32 = 480;
|
const DEFAULT_HEIGHT: i32 = 480;
|
||||||
const DEFAULT_WIDTH: i32 = 640;
|
const DEFAULT_WIDTH: i32 = 640;
|
||||||
@ -28,6 +28,7 @@ impl Browser {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
// Extras
|
// Extras
|
||||||
// connection: Arc<sqlite::Connection>,
|
// connection: Arc<sqlite::Connection>,
|
||||||
|
profile_path: PathBuf,
|
||||||
// Actions
|
// Actions
|
||||||
action_tool_debug: Arc<SimpleAction>,
|
action_tool_debug: Arc<SimpleAction>,
|
||||||
action_tool_profile_directory: Arc<SimpleAction>,
|
action_tool_profile_directory: Arc<SimpleAction>,
|
||||||
@ -100,7 +101,11 @@ impl Browser {
|
|||||||
|
|
||||||
action_tool_profile_directory.connect_activate({
|
action_tool_profile_directory.connect_activate({
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
// @TODO
|
// @TODO [4_10] https://docs.gtk.org/gtk4/class.FileLauncher.html
|
||||||
|
let _ = AppInfo::launch_default_for_uri(
|
||||||
|
&format!("file://{}", profile_path.to_string_lossy()),
|
||||||
|
Some(&AppLaunchContext::new()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
// Init GTK, start application
|
// Init GTK, start application
|
||||||
match gtk::init() {
|
match gtk::init() {
|
||||||
Ok(_) => App::new(profile_database_connection).run(),
|
Ok(_) => App::new(profile_database_connection, profile_path).run(),
|
||||||
Err(_) => ExitCode::FAILURE,
|
Err(_) => ExitCode::FAILURE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user