Comments (10)
I mean that gdk_pixbuf_save
have at minimum 5 parameters.
gdk_pixbuf_save(pb, save_path.as_ptr(), format.as_ptr(), err_[or]_, ptr::null_mut());
from gtk3-rs.
The difficulty with varargs is why they provide the _savev
and other ...v
functions. I believe there are translation implementations for &[&str]
to char**
so this should be doable.
from gtk3-rs.
Second that! I've been trying to capture a screenshot using the functions through gdk_pixbuf_sys:
let save_path = CString::new("--full-path-to-file--").unwrap();
let format = CString::new("png").unwrap();
gdk::init();
let desktop = gdk::Window::get_default_root_window();
//Init "empty" GError object
let msg = ptr::null_mut::<i8>();
let b = Box::new(GError { domain: 0, code: 0, message: msg });
let error: *mut *mut GError = &mut Box::into_raw(b);
//Result: (gdk_testing:5953): GdkPixbuf-CRITICAL **: gdk_pixbuf_save: assertion 'error == NULL || *error == NULL' failed
//GError *err = NULL;
let err = &mut ptr::null_mut::<GError>();
//Result: Process didn't exit successfully: target/debug/gdk_testing (signal: 11, SIGSEGV: invalid memory reference)
unsafe {
let pb = gdk_pixbuf_get_from_window(gdk_get_default_root_window(), 0, 0, desktop.get_width(), desktop.get_height());
println!("Channels: {}", gdk_pixbuf_get_n_channels(pb));
gdk_pixbuf_save(pb, save_path.as_ptr(), format.as_ptr(), err_[or]_);
println!("{}x{}", desktop.get_width(), desktop.get_height());
}
When I use the error variable as input to the save function I get
Result: (gdk_testing:5953): GdkPixbuf-CRITICAL **: gdk_pixbuf_save: assertion 'error == NULL || *error == NULL' failed
and for the err variable
Result: Process didn't exit successfully: target/debug/gdk_testing (signal: 11, SIGSEGV: invalid memory reference)
Probably my usage of GError, got any tips?
from gtk3-rs.
You need error
argument be null or pointer to null. We have rust class Error
as wrapper.
pub fn load_from_path(&self, path: &str) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gtk_css_provider_load_from_path(self.to_glib_none().0, path.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
from gtk3-rs.
Missed that you tried both cases :(
May be problem with last parameter, you tried pass ptr::null_mut()
after error?
from gtk3-rs.
I saw the Error struct when I searched through all sources for any reference or abstraction of GError, but I wasn't able to use it with the lower level _sys functions. Is there some way I could create an Error and convert it to GError and pass it to the _sys functions?
I tried using ptr::null_mut()
instead of &mut ptr::null_mut::<GError>()
which compiled but resulted in the same segfault.
Thanks for a response :)
from gtk3-rs.
Thank you! I can't believe I didn't understand that the "..." ment options until NULL. I went with let null: *const i32 = ptr::null();
and it worked!
Awesome :D
from gtk3-rs.
"..." is main problem why no save_*
currently, almost only gdk_pixbuf_savev
can be added 😢
from gtk3-rs.
Yeah, it's a really weird way to specify parameters :/ so it isn't technically possible to do that through Rust in a reliable way? I'm really new to it...
from gtk3-rs.
There are various save
functions now.
from gtk3-rs.
Related Issues (20)
- Unexpected plug-added event for socket realized HOT 2
- could not find system library 'gio-2.0' required by the 'gio-sys' crate HOT 6
- [BUG] Wrong return turn (u32 vs gint) for GtkNotebook append_page HOT 3
- Update to wayland-client 0.30
- [HELP] Using GTK_STOCK_REMOVE HOT 2
- the procedure entry point _divmoddi4 could not be located in the dynamic link library D:\msys32\mingw32\bin\libglib-2.0-0.dll HOT 1
- [HELP] STATUS_ACCESS_VIOLATION when right clicking an Entry widget HOT 3
- [BUG] gtk fails to compile on mispel HOT 1
- [HELP] What is best way to show error message and then close application on panic?
- Quoting C documentation regarding the use of Rust methods is not helpful HOT 2
- [BUG] Dialog and clipboard examples are dead links
- Gtk::Inhibit has been removed in very recent versions. Documentation says it's still there. HOT 5
- [HELP] How do I get the width and height of the current screen? HOT 3
- [BUG] window.rs has two fn "screen" HOT 2
- [HELP] Clipboard: missing connect_owner_change function?
- [HELP] Make a desktop widget using GTK3 bindings
- [HELP] Why doesn't the merge PRs? HOT 1
- [HELP] Access gtk_sys::GtkWidget from gtk::GtkToggleButton HOT 2
- [BUG] Unexpected lines in `cairo_threads` example running on HiDPI display
- [BUG] The examples don't compile due compilation error on atk v0.19.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gtk3-rs.