1 // This file was generated by gir (https://github.com/gtk-rs/gir)
2 // from gir-files (https://github.com/gtk-rs/gir-files)
3 // DO NOT EDIT
4 
5 use gio;
6 use glib::object::IsA;
7 use glib::translate::*;
8 use gtk_source_sys;
9 use std::fmt;
10 use Buffer;
11 use CompressionType;
12 use Encoding;
13 use File;
14 use NewlineType;
15 
16 glib_wrapper! {
17     pub struct FileLoader(Object<gtk_source_sys::GtkSourceFileLoader, gtk_source_sys::GtkSourceFileLoaderClass, FileLoaderClass>);
18 
19     match fn {
20         get_type => || gtk_source_sys::gtk_source_file_loader_get_type(),
21     }
22 }
23 
24 impl FileLoader {
new<P: IsA<Buffer>, Q: IsA<File>>(buffer: &P, file: &Q) -> FileLoader25     pub fn new<P: IsA<Buffer>, Q: IsA<File>>(buffer: &P, file: &Q) -> FileLoader {
26         skip_assert_initialized!();
27         unsafe {
28             from_glib_full(gtk_source_sys::gtk_source_file_loader_new(buffer.as_ref().to_glib_none().0, file.as_ref().to_glib_none().0))
29         }
30     }
31 
new_from_stream<P: IsA<Buffer>, Q: IsA<File>, R: IsA<gio::InputStream>>(buffer: &P, file: &Q, stream: &R) -> FileLoader32     pub fn new_from_stream<P: IsA<Buffer>, Q: IsA<File>, R: IsA<gio::InputStream>>(buffer: &P, file: &Q, stream: &R) -> FileLoader {
33         skip_assert_initialized!();
34         unsafe {
35             from_glib_full(gtk_source_sys::gtk_source_file_loader_new_from_stream(buffer.as_ref().to_glib_none().0, file.as_ref().to_glib_none().0, stream.as_ref().to_glib_none().0))
36         }
37     }
38 }
39 
40 pub const NONE_FILE_LOADER: Option<&FileLoader> = None;
41 
42 pub trait FileLoaderExt: 'static {
get_buffer(&self) -> Option<Buffer>43     fn get_buffer(&self) -> Option<Buffer>;
44 
get_compression_type(&self) -> CompressionType45     fn get_compression_type(&self) -> CompressionType;
46 
get_encoding(&self) -> Option<Encoding>47     fn get_encoding(&self) -> Option<Encoding>;
48 
get_file(&self) -> Option<File>49     fn get_file(&self) -> Option<File>;
50 
get_input_stream(&self) -> Option<gio::InputStream>51     fn get_input_stream(&self) -> Option<gio::InputStream>;
52 
get_location(&self) -> Option<gio::File>53     fn get_location(&self) -> Option<gio::File>;
54 
get_newline_type(&self) -> NewlineType55     fn get_newline_type(&self) -> NewlineType;
56 
57     //fn load_async<P: IsA<gio::Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static, R: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, progress_callback_notify: Fn() + 'static, callback: R);
58 
59     //
60     //fn load_async_future<Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, io_priority: glib::Priority, progress_callback: Q, progress_callback_notify: Fn() + 'static) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>;
61 }
62 
63 impl<O: IsA<FileLoader>> FileLoaderExt for O {
get_buffer(&self) -> Option<Buffer>64     fn get_buffer(&self) -> Option<Buffer> {
65         unsafe {
66             from_glib_none(gtk_source_sys::gtk_source_file_loader_get_buffer(self.as_ref().to_glib_none().0))
67         }
68     }
69 
get_compression_type(&self) -> CompressionType70     fn get_compression_type(&self) -> CompressionType {
71         unsafe {
72             from_glib(gtk_source_sys::gtk_source_file_loader_get_compression_type(self.as_ref().to_glib_none().0))
73         }
74     }
75 
get_encoding(&self) -> Option<Encoding>76     fn get_encoding(&self) -> Option<Encoding> {
77         unsafe {
78             from_glib_none(gtk_source_sys::gtk_source_file_loader_get_encoding(self.as_ref().to_glib_none().0))
79         }
80     }
81 
get_file(&self) -> Option<File>82     fn get_file(&self) -> Option<File> {
83         unsafe {
84             from_glib_none(gtk_source_sys::gtk_source_file_loader_get_file(self.as_ref().to_glib_none().0))
85         }
86     }
87 
get_input_stream(&self) -> Option<gio::InputStream>88     fn get_input_stream(&self) -> Option<gio::InputStream> {
89         unsafe {
90             from_glib_none(gtk_source_sys::gtk_source_file_loader_get_input_stream(self.as_ref().to_glib_none().0))
91         }
92     }
93 
get_location(&self) -> Option<gio::File>94     fn get_location(&self) -> Option<gio::File> {
95         unsafe {
96             from_glib_none(gtk_source_sys::gtk_source_file_loader_get_location(self.as_ref().to_glib_none().0))
97         }
98     }
99 
get_newline_type(&self) -> NewlineType100     fn get_newline_type(&self) -> NewlineType {
101         unsafe {
102             from_glib(gtk_source_sys::gtk_source_file_loader_get_newline_type(self.as_ref().to_glib_none().0))
103         }
104     }
105 
106     //fn load_async<P: IsA<gio::Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static, R: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, progress_callback_notify: Fn() + 'static, callback: R) {
107     //    unsafe { TODO: call gtk_source_sys:gtk_source_file_loader_load_async() }
108     //}
109 
110     //
111     //fn load_async_future<Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, io_priority: glib::Priority, progress_callback: Q, progress_callback_notify: Fn() + 'static) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
112 
113         //let progress_callback = progress_callback.map(ToOwned::to_owned);
114         //let progress_callback_notify = progress_callback_notify.map(ToOwned::to_owned);
115         //Box_::pin(gio::GioFuture::new(self, move |obj, send| {
116         //    let cancellable = gio::Cancellable::new();
117         //    obj.load_async(
118         //        io_priority,
119         //        Some(&cancellable),
120         //        progress_callback.as_ref().map(::std::borrow::Borrow::borrow),
121         //        progress_callback_notify.as_ref().map(::std::borrow::Borrow::borrow),
122         //        move |res| {
123         //            send.resolve(res);
124         //        },
125         //    );
126 
127         //    cancellable
128         //}))
129     //}
130 }
131 
132 impl fmt::Display for FileLoader {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result133     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
134         write!(f, "FileLoader")
135     }
136 }
137