Compare commits
No commits in common. "patchWorkGood" and "master" have entirely different histories.
patchWorkG
...
master
20
src/main.rs
20
src/main.rs
@ -4,8 +4,6 @@ mod boxes;
|
|||||||
mod menu;
|
mod menu;
|
||||||
mod popover;
|
mod popover;
|
||||||
|
|
||||||
use gio::SimpleAction;
|
|
||||||
use glib::clone;
|
|
||||||
use titlebar::CustomTitleBar;
|
use titlebar::CustomTitleBar;
|
||||||
use boxes::*;
|
use boxes::*;
|
||||||
use popover::CustomPopoverMenu;
|
use popover::CustomPopoverMenu;
|
||||||
@ -28,7 +26,6 @@ use gtk4::{
|
|||||||
fn main() {
|
fn main() {
|
||||||
let app = Application::new(Some("com.wyattjmiller.snespatcher"), Default::default());
|
let app = Application::new(Some("com.wyattjmiller.snespatcher"), Default::default());
|
||||||
app.connect_activate(build_ui);
|
app.connect_activate(build_ui);
|
||||||
app.set_accels_for_action("win.close", &["<Ctrl>W"]);
|
|
||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,10 +43,14 @@ fn build_ui(app: &Application) {
|
|||||||
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let builder = Builder::new();
|
||||||
|
builder.add_from_resource("/com/wyattjmiller/snespatcher/appmenu.xml").expect("Error initializing app menu!");
|
||||||
|
//println!("{:?}", builder.list_properties());
|
||||||
|
|
||||||
let app_window: Rc<ApplicationWindow> = Rc::new(ApplicationWindow::new(app));
|
let app_window: Rc<ApplicationWindow> = Rc::new(ApplicationWindow::new(app));
|
||||||
let file_picker_window: Window = Window::new();
|
let file_picker_window: Window = Window::new();
|
||||||
let popover_menu: CustomPopoverMenu = CustomPopoverMenu::new();
|
let popover_menu: CustomPopoverMenu = CustomPopoverMenu::new();
|
||||||
let header_bar: CustomTitleBar = CustomTitleBar::new();
|
let header_bar: CustomTitleBar = CustomTitleBar::new(&popover_menu);
|
||||||
let app_box: AppBox = AppBox::new();
|
let app_box: AppBox = AppBox::new();
|
||||||
let patch_box: PatchBox = PatchBox::new(&app_window);
|
let patch_box: PatchBox = PatchBox::new(&app_window);
|
||||||
let rom_box: RomBox = RomBox::new(&app_window);
|
let rom_box: RomBox = RomBox::new(&app_window);
|
||||||
@ -60,11 +61,11 @@ fn build_ui(app: &Application) {
|
|||||||
|
|
||||||
// TODO: Set popover textviews and put them in a separate file
|
// TODO: Set popover textviews and put them in a separate file
|
||||||
// set header bar methods
|
// set header bar methods
|
||||||
header_bar.set_actions();
|
|
||||||
header_bar.set_buttons();
|
header_bar.set_buttons();
|
||||||
header_bar.set_titlebar();
|
header_bar.set_titlebar();
|
||||||
header_bar.set_window(&app_window);
|
header_bar.set_window(&app_window);
|
||||||
header_bar.click_run_button();
|
header_bar.click_run_button();
|
||||||
|
header_bar.click_menu();
|
||||||
|
|
||||||
// set patch box methods
|
// set patch box methods
|
||||||
patch_box.set_label();
|
patch_box.set_label();
|
||||||
@ -85,15 +86,6 @@ fn build_ui(app: &Application) {
|
|||||||
app_window.set_title(Some("SNES Patcher"));
|
app_window.set_title(Some("SNES Patcher"));
|
||||||
app_window.set_resizable(false);
|
app_window.set_resizable(false);
|
||||||
app_window.set_child(Some(&app_box.app_box));
|
app_window.set_child(Some(&app_box.app_box));
|
||||||
|
|
||||||
// keyboard shortcuts
|
|
||||||
let action_close = SimpleAction::new("close", None);
|
|
||||||
action_close.connect_activate(clone!(@weak app_window => move |_, _| {
|
|
||||||
app_window.close();
|
|
||||||
}));
|
|
||||||
app_window.add_action(&action_close);
|
|
||||||
|
|
||||||
// show the app
|
|
||||||
app_window.show();
|
app_window.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,23 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
use futures::executor::block_on;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
|
use gtk4::subclass::prelude::*;
|
||||||
use gtk4::{
|
use gtk4::{
|
||||||
AboutDialog,
|
AboutDialog,
|
||||||
|
gdk::Paintable,
|
||||||
glib::*,
|
glib::*,
|
||||||
|
ApplicationWindow,
|
||||||
|
HeaderBar,
|
||||||
Button,
|
Button,
|
||||||
|
Window,
|
||||||
Popover,
|
Popover,
|
||||||
|
Builder,
|
||||||
License,
|
License,
|
||||||
|
IconTheme,
|
||||||
|
IconLookupFlags,
|
||||||
|
TextDirection,
|
||||||
|
MenuButton,
|
||||||
|
TextView,
|
||||||
Box,
|
Box,
|
||||||
Orientation,
|
Orientation,
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use futures::executor::block_on;
|
use futures::executor::block_on;
|
||||||
use gio::{Menu, MenuItem, SimpleAction, SimpleActionGroup};
|
use gtk4::{prelude::*};
|
||||||
use gtk4::builders::PopoverMenuBuilder;
|
|
||||||
use gtk4::{prelude::*, PopoverMenu, AboutDialog, License};
|
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
use gtk4::{
|
use gtk4::{
|
||||||
gdk::Paintable,
|
gdk::Paintable,
|
||||||
@ -21,26 +19,24 @@ use gtk4::{
|
|||||||
|
|
||||||
use crate::popover::CustomPopoverMenu;
|
use crate::popover::CustomPopoverMenu;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Downgrade)]
|
||||||
pub struct CustomTitleBar {
|
pub struct CustomTitleBar {
|
||||||
pub window: Window,
|
pub window: Window,
|
||||||
pub titlebar: HeaderBar,
|
pub titlebar: HeaderBar,
|
||||||
pub run_button: Button,
|
pub run_button: Button,
|
||||||
pub menu_button: MenuButton,
|
pub menu_button: MenuButton,
|
||||||
pub menu: Menu,
|
pub popover_menu: CustomPopoverMenu,
|
||||||
pub menu_actions: SimpleActionGroup,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CustomTitleBar {
|
impl CustomTitleBar {
|
||||||
pub fn new() -> CustomTitleBar {
|
pub fn new(pop: &CustomPopoverMenu) -> CustomTitleBar {
|
||||||
// loading PopoverMenu logic goes here
|
// loading PopoverMenu logic goes here
|
||||||
CustomTitleBar {
|
CustomTitleBar {
|
||||||
window: Window::new(),
|
window: Window::new(),
|
||||||
titlebar: HeaderBar::new(),
|
titlebar: HeaderBar::new(),
|
||||||
run_button: Button::new(),
|
run_button: Button::new(),
|
||||||
menu_button: MenuButton::new(),
|
menu_button: MenuButton::new(),
|
||||||
menu: Menu::new(),
|
popover_menu: pop.clone(),
|
||||||
menu_actions: SimpleActionGroup::new(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,39 +55,8 @@ impl CustomTitleBar {
|
|||||||
// symbolic
|
// symbolic
|
||||||
// let menu_button = IconTheme::new();
|
// let menu_button = IconTheme::new();
|
||||||
// menu_button.lookup_icon("open-menu-symbolic", &[], 16, 1, TextDirection::Ltr, IconLookupFlags::empty());
|
// menu_button.lookup_icon("open-menu-symbolic", &[], 16, 1, TextDirection::Ltr, IconLookupFlags::empty());
|
||||||
//self.menu_button.set_popover(Some(&self.popover_menu.popover));
|
self.menu_button.set_popover(Some(&self.popover_menu.popover));
|
||||||
self.menu.append(Some("About"), Some("about_action"));
|
|
||||||
self.menu.append(Some("Keyboard Shortcuts"), None);
|
|
||||||
self.menu.append(Some("Quit"), None);
|
|
||||||
let popover_menu = Some(PopoverMenu::builder().menu_model(&self.menu).build());
|
|
||||||
self.menu_button.set_popover(Some(&popover_menu.unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_actions(&self) {
|
|
||||||
// about action
|
|
||||||
let about_action = SimpleAction::new("about_action", None);
|
|
||||||
about_action.set_enabled(true);
|
|
||||||
about_action.connect_activate(clone!(@strong self as this =>
|
|
||||||
move |_, _| {
|
|
||||||
let about_dialog = AboutDialog::builder()
|
|
||||||
.program_name("SNESPatcher")
|
|
||||||
.version("0.1.0")
|
|
||||||
.comments("GTK4 app to patch your SNES ROMs!")
|
|
||||||
.authors(["Wyatt J. Miller".to_string()].to_vec())
|
|
||||||
.documenters(["Wyatt J. Miller".to_string()].to_vec())
|
|
||||||
.license_type(License::Mpl20)
|
|
||||||
.website("https://scm.wyattjmiller.com/wymiller/snespatcher")
|
|
||||||
.website_label("Website?")
|
|
||||||
.modal(false)
|
|
||||||
.can_focus(true)
|
|
||||||
//.child(&window)
|
|
||||||
.build();
|
|
||||||
about_dialog.show();
|
|
||||||
}));
|
|
||||||
|
|
||||||
// add actions to the menu
|
|
||||||
self.menu_actions.add_action(&about_action);
|
|
||||||
//println!("{:?}", self.menu_actions.is_action_enabled("About"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn click_run_button(&self) {
|
pub fn click_run_button(&self) {
|
||||||
@ -100,6 +65,13 @@ impl CustomTitleBar {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn click_menu(&self) {
|
||||||
|
// self.menu_button.connect_clicked(clone!(@weak self as this =>
|
||||||
|
// move |_| {
|
||||||
|
// this.popover.show();
|
||||||
|
// }));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_window(&self, window: &ApplicationWindow) {
|
pub fn set_window(&self, window: &ApplicationWindow) {
|
||||||
window.set_titlebar(Some(&self.titlebar));
|
window.set_titlebar(Some(&self.titlebar));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user