audrey/src/ui/window.rs

40 lines
1.1 KiB
Rust
Raw Normal View History

2024-10-29 13:02:29 +00:00
mod ffi {
use gtk::glib;
#[repr(C)]
2024-10-29 14:46:33 +00:00
pub struct AudreyUiWindow {
2024-10-29 13:02:29 +00:00
parent_instance: adw::ffi::AdwApplicationWindow,
}
#[repr(C)]
2024-10-29 14:46:33 +00:00
pub struct AudreyUiWindowClass {
2024-10-29 13:02:29 +00:00
parent_class: adw::ffi::AdwApplicationWindowClass,
}
extern "C" {
2024-10-29 14:46:33 +00:00
pub fn audrey_ui_window_get_type() -> glib::ffi::GType;
pub fn audrey_ui_window_new(app: *mut gtk::ffi::GtkApplication) -> *mut AudreyUiWindow;
2024-10-29 13:02:29 +00:00
}
}
use adw::prelude::*;
use gtk::{gio, glib};
glib::wrapper! {
2024-10-29 14:46:33 +00:00
pub struct Window(Object<ffi::AudreyUiWindow, ffi::AudreyUiWindowClass>)
2024-10-29 13:02:29 +00:00
@extends adw::ApplicationWindow, gtk::ApplicationWindow, gtk::Window, gtk::Widget,
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
match fn {
2024-10-29 14:46:33 +00:00
type_ => || ffi::audrey_ui_window_get_type(),
2024-10-29 13:02:29 +00:00
}
}
impl Window {
pub fn new(app: &impl IsA<gtk::Application>) -> Self {
use glib::translate::*;
2024-10-29 14:46:33 +00:00
unsafe { from_glib_none(ffi::audrey_ui_window_new(app.as_ref().to_glib_none().0)) }
2024-10-29 13:02:29 +00:00
}
}