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

Commit

Permalink
gio: Make methods of *Impl traits take Self::Type
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Nov 13, 2020
1 parent f1086f8 commit 0ae7970
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 300 deletions.
4 changes: 2 additions & 2 deletions examples/src/bin/basic_subclass.rs
Expand Up @@ -154,7 +154,7 @@ mod imp_app {
// `gio::Application::activate` is what gets called when the
// application is launched by the desktop environment and
// aksed to present itself.
fn activate(&self, app: &gio::Application) {
fn activate(&self, app: &Self::Type) {
let app = app.downcast_ref::<super::SimpleApplication>().unwrap();
let priv_ = SimpleApplication::from_instance(app);
let window = priv_
Expand All @@ -172,7 +172,7 @@ mod imp_app {
//
// Due to this, we create and initialize the `SimpleWindow` widget
// here. Widgets can't be created before `startup` has been called.
fn startup(&self, app: &gio::Application) {
fn startup(&self, app: &Self::Type) {
self.parent_startup(app);

let app = app.downcast_ref::<super::SimpleApplication>().unwrap();
Expand Down
14 changes: 7 additions & 7 deletions gio/src/read_input_stream.rs
Expand Up @@ -49,7 +49,7 @@ mod imp {
impl InputStreamImpl for ReadInputStream {
fn read(
&self,
_stream: &InputStream,
_stream: &Self::Type,
buffer: &mut [u8],
_cancellable: Option<&crate::Cancellable>,
) -> Result<usize, glib::Error> {
Expand All @@ -75,7 +75,7 @@ mod imp {

fn close(
&self,
_stream: &InputStream,
_stream: &Self::Type,
_cancellable: Option<&crate::Cancellable>,
) -> Result<(), glib::Error> {
let _ = self.read.borrow_mut().take();
Expand All @@ -84,7 +84,7 @@ mod imp {
}

impl SeekableImpl for ReadInputStream {
fn tell(&self, _seekable: &crate::Seekable) -> i64 {
fn tell(&self, _seekable: &Self::Type) -> i64 {
// XXX: stream_position is not stable yet
// let mut read = self.read.borrow_mut();
// match *read {
Expand All @@ -96,7 +96,7 @@ mod imp {
-1
}

fn can_seek(&self, _seekable: &crate::Seekable) -> bool {
fn can_seek(&self, _seekable: &Self::Type) -> bool {
let read = self.read.borrow();
match *read {
Some(Reader::ReadSeek(_)) => true,
Expand All @@ -106,7 +106,7 @@ mod imp {

fn seek(
&self,
_seekable: &crate::Seekable,
_seekable: &Self::Type,
offset: i64,
type_: glib::SeekType,
_cancellable: Option<&crate::Cancellable>,
Expand Down Expand Up @@ -146,13 +146,13 @@ mod imp {
}
}

fn can_truncate(&self, _seekable: &crate::Seekable) -> bool {
fn can_truncate(&self, _seekable: &Self::Type) -> bool {
false
}

fn truncate(
&self,
_seekable: &crate::Seekable,
_seekable: &Self::Type,
_offset: i64,
_cancellable: Option<&crate::Cancellable>,
) -> Result<(), glib::Error> {
Expand Down

0 comments on commit 0ae7970

Please sign in to comment.