audrey/src/ui/window.rs

40 lines
1 KiB
Rust
Raw Normal View History

2024-10-29 13:02:29 +00:00
mod ffi {
use gtk::glib;
#[repr(C)]
pub struct UiWindow {
parent_instance: adw::ffi::AdwApplicationWindow,
}
#[repr(C)]
pub struct UiWindowClass {
parent_class: adw::ffi::AdwApplicationWindowClass,
}
extern "C" {
pub fn ui_window_get_type() -> glib::ffi::GType;
pub fn ui_window_new(app: *mut gtk::ffi::GtkApplication) -> *mut UiWindow;
}
}
use adw::prelude::*;
use gtk::{gio, glib};
glib::wrapper! {
pub struct Window(Object<ffi::UiWindow, ffi::UiWindowClass>)
@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 {
type_ => || ffi::ui_window_get_type(),
}
}
impl Window {
pub fn new(app: &impl IsA<gtk::Application>) -> Self {
use glib::translate::*;
unsafe { from_glib_none(ffi::ui_window_new(app.as_ref().to_glib_none().0)) }
}
}