Giter Club home page Giter Club logo

Comments (7)

GuillaumeGomez avatar GuillaumeGomez commented on June 21, 2024

What is the i32 for in here?

from gio.

daa84 avatar daa84 commented on June 21, 2024

i32 is n_files - count of files in [File] array
as i understand **GFile is not finished with null value

from gio.

GuillaumeGomez avatar GuillaumeGomez commented on June 21, 2024

Yes, that's my point. n_files is useless in Rust since it's supposed to be the length of the slice.

from gio.

daa84 avatar daa84 commented on June 21, 2024

Ok, but how to implement this properly? Gir generator does not support such kind of thing? Does it need to implement this manually? Or maybe some converter already exists?

from gio.

GuillaumeGomez avatar GuillaumeGomez commented on June 21, 2024

I wonder. I think we already did it but not sure if it was in gir or manually...

cc @EPashkin

from gio.

EPashkin avatar EPashkin commented on June 21, 2024

Yes, this need be manual. Something like this:

impl<O: IsA<Application> + IsA<glib::object::Object>> ApplicationExtManual for O {
   fn connect_open<F: Fn(&Self, &[File], &str) + 'static>(&self, f: F) -> u64 {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &[File], &str) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "open",
                transmute(open_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}
unsafe extern "C" fn open_trampoline<P>(this: *mut ffi::GApplication, files: *const *mut ffi::GFile, n_files: libc::c_int, hint: *mut libc::c_char, f: glib_ffi::gpointer)
where P: IsA<Application> {
    callback_guard!();
    let f: &Box_<Fn(&P, &[File], &str) + 'static> = transmute(f);
    let files: Vec<File> = FromGlibPtrContainer::from_glib_none_num(files, n_files as usize);
    f(&Application::from_glib_none(this).downcast_unchecked(), &files[..], &String::from_glib_none(hint))
}

from gio.

daa84 avatar daa84 commented on June 21, 2024

Thanks, i try 😄

from gio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.