mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
draft welcome dialog with profile selection
This commit is contained in:
parent
57594a3fc8
commit
b0ee52c3f4
@ -1,11 +1,13 @@
|
|||||||
mod about;
|
mod about;
|
||||||
mod action;
|
mod action;
|
||||||
mod database;
|
mod database;
|
||||||
|
mod welcome;
|
||||||
mod widget;
|
mod widget;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
use about::About;
|
use about::About;
|
||||||
use action::Action;
|
use action::Action;
|
||||||
|
use welcome::Welcome;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
use window::Window;
|
use window::Window;
|
||||||
|
|
||||||
@ -21,6 +23,7 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
pub struct Browser {
|
pub struct Browser {
|
||||||
action: Rc<Action>,
|
action: Rc<Action>,
|
||||||
|
profile: Rc<Profile>,
|
||||||
widget: Rc<Widget>,
|
widget: Rc<Widget>,
|
||||||
window: Rc<Window>,
|
window: Rc<Window>,
|
||||||
}
|
}
|
||||||
@ -71,6 +74,7 @@ impl Browser {
|
|||||||
});
|
});
|
||||||
|
|
||||||
action.profile().connect_activate({
|
action.profile().connect_activate({
|
||||||
|
let profile = profile.clone();
|
||||||
move || {
|
move || {
|
||||||
FileLauncher::new(Some(&File::for_path(profile.config_path()))).launch(
|
FileLauncher::new(Some(&File::for_path(profile.config_path()))).launch(
|
||||||
None::<>k::Window>,
|
None::<>k::Window>,
|
||||||
@ -92,6 +96,7 @@ impl Browser {
|
|||||||
// Return new activated `Self`
|
// Return new activated `Self`
|
||||||
Self {
|
Self {
|
||||||
action,
|
action,
|
||||||
|
profile,
|
||||||
widget,
|
widget,
|
||||||
window,
|
window,
|
||||||
}
|
}
|
||||||
@ -159,6 +164,10 @@ impl Browser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self) {
|
pub fn init(&self) {
|
||||||
|
// Show welcome dialog on profile not selected yet (e.g. first launch) @TODO
|
||||||
|
// Welcome::new(self.profile.clone()).present(Some(self.widget.gobject()));
|
||||||
|
|
||||||
|
// Init main window
|
||||||
self.window.init();
|
self.window.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
src/app/browser/welcome.rs
Normal file
30
src/app/browser/welcome.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
mod widget;
|
||||||
|
use widget::Widget;
|
||||||
|
|
||||||
|
use crate::profile::Profile;
|
||||||
|
use gtk::prelude::IsA;
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
pub struct Welcome {
|
||||||
|
profile: Rc<Profile>,
|
||||||
|
widget: Rc<Widget>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Welcome {
|
||||||
|
// Construct
|
||||||
|
|
||||||
|
/// Create new `Self` for given Profile
|
||||||
|
pub fn new(profile: Rc<Profile>) -> Self {
|
||||||
|
Self {
|
||||||
|
profile,
|
||||||
|
widget: Rc::new(Widget::new()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
|
||||||
|
/// Show dialog for parent [Window](https://docs.gtk.org/gtk4/class.Window.html)
|
||||||
|
pub fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
|
||||||
|
self.widget.present(parent);
|
||||||
|
}
|
||||||
|
}
|
47
src/app/browser/welcome/widget.rs
Normal file
47
src/app/browser/welcome/widget.rs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
use adw::{
|
||||||
|
prelude::{AdwDialogExt, AlertDialogExtManual},
|
||||||
|
AlertDialog,
|
||||||
|
};
|
||||||
|
use gtk::prelude::IsA;
|
||||||
|
|
||||||
|
const HEADING: &str = "Welcome!";
|
||||||
|
const BODY: &str = "Select profile for browser data";
|
||||||
|
const RESPONSE_QUIT: (&str, &str) = ("quit", "Quit");
|
||||||
|
const RESPONSE_CREATE: (&str, &str) = ("create", "Create new profile");
|
||||||
|
|
||||||
|
pub struct Widget {
|
||||||
|
gobject: AlertDialog,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Widget {
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/// Create new `Self`
|
||||||
|
pub fn new() -> Self {
|
||||||
|
// Init gobject
|
||||||
|
let gobject = AlertDialog::builder()
|
||||||
|
.heading(HEADING)
|
||||||
|
.body(BODY)
|
||||||
|
.default_response(RESPONSE_QUIT.1)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
gobject.add_responses(&[RESPONSE_QUIT, RESPONSE_CREATE]);
|
||||||
|
|
||||||
|
// Return new `Self`
|
||||||
|
Self { gobject }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
|
||||||
|
/// Show dialog for parent [Window](https://docs.gtk.org/gtk4/class.Window.html)
|
||||||
|
pub fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
|
||||||
|
self.gobject.present(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @TODO not in use
|
||||||
|
/// Get reference to GObject
|
||||||
|
///
|
||||||
|
pub fn gobject(&self) -> &AlertDialog {
|
||||||
|
&self.gobject
|
||||||
|
} */
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user