Add a menu bar option to the desktop config (#2107)

* add an option to set a custom menu in the desktop config

* Fix rename issue

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2024-03-18 22:36:47 -07:00
1 parent 10d361a44e
commit d442dac168
11 files changed
+152 -95

No files matched your search

+5 -7
View File
@@ -1,5 +1,5 @@
use crate::{
config::{Config, WindowCloseBehaviour},
config::{Config, WindowCloseBehavior},
element::DesktopElement,
event_handlers::WindowEventHandlers,
file_upload::{DesktopFileDragEvent, DesktopFileUploadForm, FileDialogRequest},
@@ -33,7 +33,7 @@ pub(crate) struct App {
// Stuff we need mutable access to
pub(crate) control_flow: ControlFlow,
pub(crate) is_visible_before_start: bool,
pub(crate) window_behavior: WindowCloseBehaviour,
pub(crate) window_behavior: WindowCloseBehavior,
pub(crate) webviews: HashMap<WindowId, WebviewInstance>,
/// This single blob of state is shared between all the windows so they have access to the runtime state
@@ -43,8 +43,6 @@ pub(crate) struct App {
}
/// A bundle of state shared between all the windows, providing a way for us to communicate with running webview.
///
/// Todo: everything in this struct is wrapped in Rc<>, but we really only need the one top-level refcell
pub(crate) struct SharedContext {
pub(crate) event_handlers: WindowEventHandlers,
pub(crate) pending_webviews: RefCell<Vec<WebviewInstance>>,
@@ -58,7 +56,7 @@ impl App {
let event_loop = EventLoopBuilder::<UserWindowEvent>::with_user_event().build();
let app = Self {
window_behavior: cfg.last_window_close_behaviour,
window_behavior: cfg.last_window_close_behavior,
is_visible_before_start: true,
webviews: HashMap::new(),
control_flow: ControlFlow::Wait,
@@ -128,7 +126,7 @@ impl App {
}
pub fn handle_close_requested(&mut self, id: WindowId) {
use WindowCloseBehaviour::*;
use WindowCloseBehavior::*;
match self.window_behavior {
LastWindowExitsApp => {
@@ -156,7 +154,7 @@ impl App {
if matches!(
self.window_behavior,
WindowCloseBehaviour::LastWindowExitsApp
WindowCloseBehavior::LastWindowExitsApp
) && self.webviews.is_empty()
{
self.control_flow = ControlFlow::Exit