audrey/src/ui/window.rs

46 lines
1.4 KiB
Rust
Raw Normal View History

2024-11-01 11:11:49 +00:00
pub mod ffi {
2024-10-29 13:02:29 +00:00
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-11-01 12:50:29 +00:00
pub fn audrey_ui_window_get_playbin(
self_: *mut AudreyUiWindow,
) -> *mut crate::playbin::ffi::AudreyPlaybin;
2024-10-29 13:02:29 +00:00
}
}
use adw::prelude::*;
2024-11-01 12:50:29 +00:00
use glib::translate::{from_glib_none, ToGlibPtr};
2024-10-29 13:02:29 +00:00
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 {
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
}
2024-11-01 12:50:29 +00:00
pub fn playbin(&self) -> Option<crate::Playbin> {
unsafe { from_glib_none(ffi::audrey_ui_window_get_playbin(self.to_glib_none().0)) }
}
2024-10-29 13:02:29 +00:00
}