-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #270 kicking off work on gtk4 migration help is appreciated
- Loading branch information
Showing
16 changed files
with
782 additions
and
1,720 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#[cfg(target_os = "linux")] | ||
use gtk4::prelude::*; | ||
#[cfg(target_os = "linux")] | ||
use keyboard_types::{Code, Modifiers}; | ||
#[cfg(target_os = "linux")] | ||
use muda::{accelerator::Accelerator, MenuEvent}; | ||
|
||
#[cfg(target_os = "linux")] | ||
fn main() { | ||
// Create a new application | ||
let application = gtk4::Application::builder() | ||
.application_id("com.github.gtk4-rs.examples.menubar") | ||
.build(); | ||
application.connect_startup(on_startup); | ||
application.connect_activate(on_activate); | ||
application.run(); | ||
} | ||
|
||
#[cfg(target_os = "linux")] | ||
fn on_startup(_: >k4::Application) { | ||
MenuEvent::set_event_handler(Some(|event| { | ||
println!("{event:?}"); | ||
})); | ||
} | ||
|
||
#[cfg(target_os = "linux")] | ||
fn on_activate(application: >k4::Application) { | ||
let window = gtk4::ApplicationWindow::builder() | ||
.application(application) | ||
.title("Menubar Example") | ||
.default_width(350) | ||
.default_height(350) | ||
.show_menubar(true) | ||
.build(); | ||
|
||
window.present(); | ||
|
||
let menubar = { | ||
// let file_menu = { | ||
// let about_menu_item = muda::MenuItem::new("About", true, None); | ||
// let quit_menu_item = muda::MenuItem::new( | ||
// "About", | ||
// true, | ||
// Some(Accelerator::new(Modifiers::CONTROL, Code::KeyQ)), | ||
// ); | ||
|
||
// let file_menu = muda::Submenu::new("File", true); | ||
// file_menu.append(&about_menu_item).unwrap(); | ||
// file_menu.append(&quit_menu_item).unwrap(); | ||
// file_menu | ||
// }; | ||
|
||
let menubar = muda::Menu::new(); | ||
// menubar.append(&file_menu).unwrap(); | ||
|
||
menubar | ||
}; | ||
|
||
menubar | ||
.init_for_gtk_window(&window, None::<>k4::Window>) | ||
.unwrap(); | ||
} | ||
|
||
#[cfg(not(target_os = "linux"))] | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.