Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

In glib_object_wrapper!, use generic Class type instead defining a struct #10

Merged
merged 2 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/src/bin/basic_subclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ mod imp_win {
}

glib_wrapper! {
pub struct SimpleWindow(ObjectSubclass<imp_win::SimpleWindow, SimpleWindowClass>)
pub struct SimpleWindow(ObjectSubclass<imp_win::SimpleWindow>)
@extends gtk::Widget, gtk::Container, gtk::Bin, gtk::Window, gtk::ApplicationWindow;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/listbox_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ mod row_data {
// Public part of the RowData type. This behaves like a normal gtk-rs-style GObject
// binding
glib_wrapper! {
pub struct RowData(ObjectSubclass<imp::RowData, RowDataClass>);
pub struct RowData(ObjectSubclass<imp::RowData>);
}

// Constructor for new instances. This simply calls glib::Object::new() with
Expand Down
8 changes: 4 additions & 4 deletions gio/src/subclass/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ impl<T: ApplicationImpl> ApplicationImplExt for T {
}
}

unsafe impl<T: ApplicationImpl> IsSubclassable<T> for ApplicationClass {
fn override_vfuncs(&mut self) {
<glib::ObjectClass as IsSubclassable<T>>::override_vfuncs(self);
unsafe impl<T: ApplicationImpl> IsSubclassable<T> for Application {
fn override_vfuncs(class: &mut ::glib::object::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(class);
unsafe {
let klass = &mut *(self as *mut Self as *mut gio_sys::GApplicationClass);
let klass = &mut *(class.as_mut() as *mut gio_sys::GApplicationClass);
klass.activate = Some(application_activate::<T>);
klass.after_emit = Some(application_after_emit::<T>);
klass.before_emit = Some(application_before_emit::<T>);
Expand Down
8 changes: 4 additions & 4 deletions gio/src/subclass/input_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ impl<T: InputStreamImpl> InputStreamImplExt for T {
}
}

unsafe impl<T: InputStreamImpl> IsSubclassable<T> for InputStreamClass {
fn override_vfuncs(&mut self) {
<glib::ObjectClass as IsSubclassable<T>>::override_vfuncs(self);
unsafe impl<T: InputStreamImpl> IsSubclassable<T> for InputStream {
fn override_vfuncs(class: &mut ::glib::object::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(class);
unsafe {
let klass = &mut *(self as *mut Self as *mut gio_sys::GInputStreamClass);
let klass = &mut *(class.as_mut() as *mut gio_sys::GInputStreamClass);
klass.read_fn = Some(stream_read::<T>);
klass.close_fn = Some(stream_close::<T>);
klass.skip = Some(stream_skip::<T>);
Expand Down
8 changes: 4 additions & 4 deletions gio/src/subclass/io_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ impl<T: IOStreamImpl> IOStreamImplExt for T {
}
}

unsafe impl<T: IOStreamImpl> IsSubclassable<T> for IOStreamClass {
fn override_vfuncs(&mut self) {
<glib::ObjectClass as IsSubclassable<T>>::override_vfuncs(self);
unsafe impl<T: IOStreamImpl> IsSubclassable<T> for IOStream {
fn override_vfuncs(class: &mut ::glib::object::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(class);
unsafe {
let klass = &mut *(self as *mut Self as *mut gio_sys::GIOStreamClass);
let klass = &mut *(class.as_mut() as *mut gio_sys::GIOStreamClass);
klass.get_input_stream = Some(stream_get_input_stream::<T>);
klass.get_output_stream = Some(stream_get_output_stream::<T>);
klass.close_fn = Some(stream_close::<T>);
Expand Down
8 changes: 4 additions & 4 deletions gio/src/subclass/output_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ impl<T: OutputStreamImpl> OutputStreamImplExt for T {
}
}

unsafe impl<T: OutputStreamImpl> IsSubclassable<T> for OutputStreamClass {
fn override_vfuncs(&mut self) {
<glib::ObjectClass as IsSubclassable<T>>::override_vfuncs(self);
unsafe impl<T: OutputStreamImpl> IsSubclassable<T> for OutputStream {
fn override_vfuncs(class: &mut ::glib::object::Class<Self>) {
<glib::Object as IsSubclassable<T>>::override_vfuncs(class);
unsafe {
let klass = &mut *(self as *mut Self as *mut gio_sys::GOutputStreamClass);
let klass = &mut *(class.as_mut() as *mut gio_sys::GOutputStreamClass);
klass.write_fn = Some(stream_write::<T>);
klass.close_fn = Some(stream_close::<T>);
klass.flush = Some(stream_flush::<T>);
Expand Down
4 changes: 2 additions & 2 deletions glib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ pub use closure::Closure;
pub use error::{BoolError, Error};
pub use file_error::FileError;
pub use object::{
Cast, InitiallyUnowned, InitiallyUnownedClass, IsA, IsClassFor, Object, ObjectClass, ObjectExt,
ObjectType, SendWeakRef, WeakRef,
Cast, InitiallyUnowned, InitiallyUnownedClass, IsA, Object, ObjectClass, ObjectExt, ObjectType,
SendWeakRef, WeakRef,
};
pub use signal::{
signal_handler_block, signal_handler_disconnect, signal_handler_unblock,
Expand Down
Loading