gtk: update to gtk-rs git

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-03-12 13:11:35 +04:00
parent 408baa481e
commit d3de3efd75
5 changed files with 9 additions and 55 deletions

View File

@ -25,14 +25,11 @@ gst-audio = { package = "gstreamer-audio", version = "0.16.5" }
[dependencies.gtk] [dependencies.gtk]
package = "gtk4" package = "gtk4"
git = "https://github.com/gtk-rs/gtk4-rs" git = "https://github.com/gtk-rs/gtk4-rs"
rev = "c43025157b12dba1112fad55962966769908a269"
[dependencies.gdk-wl] [dependencies.gdk-wl]
package = "gdk4-wayland" package = "gdk4-wayland"
git = "https://github.com/gtk-rs/gtk4-rs" git = "https://github.com/gtk-rs/gtk4-rs"
rev = "c43025157b12dba1112fad55962966769908a269"
[dependencies.gdk-x11] [dependencies.gdk-x11]
package = "gdk4-x11" package = "gdk4-x11"
git = "https://github.com/gtk-rs/gtk4-rs" git = "https://github.com/gtk-rs/gtk4-rs"
rev = "c43025157b12dba1112fad55962966769908a269"

View File

@ -17,9 +17,8 @@ use zbus::Connection;
mod imp { mod imp {
use super::*; use super::*;
use glib::subclass;
#[derive(Debug)] #[derive(Debug, Default)]
pub struct QemuApplication { pub struct QemuApplication {
pub window: OnceCell<WeakRef<QemuApplicationWindow>>, pub window: OnceCell<WeakRef<QemuApplicationWindow>>,
pub conn: OnceCell<Connection>, pub conn: OnceCell<Connection>,
@ -27,24 +26,11 @@ mod imp {
pub audio: OnceCell<GstAudio>, pub audio: OnceCell<GstAudio>,
} }
#[glib::object_subclass]
impl ObjectSubclass for QemuApplication { impl ObjectSubclass for QemuApplication {
const NAME: &'static str = "QemuApplication"; const NAME: &'static str = "QemuApplication";
type Type = super::QemuApplication; type Type = super::QemuApplication;
type ParentType = gtk::Application; type ParentType = gtk::Application;
type Interfaces = ();
type Instance = subclass::simple::InstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
window: OnceCell::new(),
conn: OnceCell::new(),
addr: OnceCell::new(),
audio: OnceCell::new(),
}
}
} }
impl ObjectImpl for QemuApplication {} impl ObjectImpl for QemuApplication {}

View File

@ -12,7 +12,6 @@ use qemu_display_listener::{Console, ConsoleEvent as Event, MouseButton};
mod imp { mod imp {
use super::*; use super::*;
use glib::subclass;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
#[derive(Debug, CompositeTemplate, Default)] #[derive(Debug, CompositeTemplate, Default)]
@ -26,25 +25,17 @@ mod imp {
pub wait_rendering: Cell<usize>, pub wait_rendering: Cell<usize>,
} }
#[glib::object_subclass]
impl ObjectSubclass for QemuConsole { impl ObjectSubclass for QemuConsole {
const NAME: &'static str = "QemuConsole"; const NAME: &'static str = "QemuConsole";
type Type = super::QemuConsole; type Type = super::QemuConsole;
type ParentType = gtk::Widget; type ParentType = gtk::Widget;
type Interfaces = ();
type Instance = subclass::simple::InstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self::default()
}
fn class_init(klass: &mut Self::Class) { fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass); Self::bind_template(klass);
} }
fn instance_init(obj: &glib::subclass::InitializingObject<Self::Type>) { fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template(); obj.init_template();
} }
} }
@ -190,7 +181,7 @@ impl QemuConsole {
priv_.area.attach_buffers(); priv_.area.attach_buffers();
let _ = unsafe { let _ = unsafe {
glib::Object::from_glib_borrow(priv_.area.as_ptr() as *mut glib::gobject_ffi::GObject) glib::Object::from_glib_borrow(priv_.area.as_ptr() as *mut glib::gobject_ffi::GObject)
.emit("render", &[&priv_.area.get_context().as_ref()]) .emit_by_name("render", &[&priv_.area.get_context().as_ref()])
.unwrap() .unwrap()
}; };
priv_.area.queue_draw(); priv_.area.queue_draw();

View File

@ -14,9 +14,9 @@ use qemu_display_listener::{Scanout, ScanoutDMABUF, Update};
mod imp { mod imp {
use super::*; use super::*;
use glib::subclass;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
#[derive(Default)]
pub struct QemuConsoleArea { pub struct QemuConsoleArea {
pub tex_id: Cell<GLuint>, pub tex_id: Cell<GLuint>,
pub texture_blit_vao: Cell<GLuint>, pub texture_blit_vao: Cell<GLuint>,
@ -26,26 +26,11 @@ mod imp {
pub scanout_size: Cell<(u32, u32)>, pub scanout_size: Cell<(u32, u32)>,
} }
#[glib::object_subclass]
impl ObjectSubclass for QemuConsoleArea { impl ObjectSubclass for QemuConsoleArea {
const NAME: &'static str = "QemuConsoleArea"; const NAME: &'static str = "QemuConsoleArea";
type Type = super::QemuConsoleArea; type Type = super::QemuConsoleArea;
type ParentType = gtk::GLArea; type ParentType = gtk::GLArea;
type Interfaces = ();
type Instance = subclass::simple::InstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
tex_id: Cell::new(0),
texture_blit_vao: Cell::new(0),
texture_blit_prog: Cell::new(0),
texture_blit_flip_prog: Cell::new(0),
scanout: Cell::new(None),
scanout_size: Cell::new((0, 0)),
}
}
fn class_init(_klass: &mut Self::Class) { fn class_init(_klass: &mut Self::Class) {
// GL loading could be done earlier? // GL loading could be done earlier?

View File

@ -11,7 +11,6 @@ use qemu_display_listener::Console;
mod imp { mod imp {
use super::*; use super::*;
use glib::subclass;
#[derive(Debug, CompositeTemplate)] #[derive(Debug, CompositeTemplate)]
#[template(resource = "/org/qemu/gtk4/window.ui")] #[template(resource = "/org/qemu/gtk4/window.ui")]
@ -23,15 +22,11 @@ mod imp {
pub settings: gio::Settings, pub settings: gio::Settings,
} }
#[glib::object_subclass]
impl ObjectSubclass for QemuApplicationWindow { impl ObjectSubclass for QemuApplicationWindow {
const NAME: &'static str = "QemuApplicationWindow"; const NAME: &'static str = "QemuApplicationWindow";
type Type = super::QemuApplicationWindow; type Type = super::QemuApplicationWindow;
type ParentType = gtk::ApplicationWindow; type ParentType = gtk::ApplicationWindow;
type Interfaces = ();
type Instance = subclass::simple::InstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self { fn new() -> Self {
Self { Self {
@ -46,7 +41,7 @@ mod imp {
} }
// You must call `Widget`'s `init_template()` within `instance_init()`. // You must call `Widget`'s `init_template()` within `instance_init()`.
fn instance_init(obj: &glib::subclass::InitializingObject<Self::Type>) { fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template(); obj.init_template();
} }
} }