Closed mmMike closed 3 years ago
Which version of gtk4 are you using?
Is it already possible to compile a gtk4-rs application on Windows?
No idea, patches to make it work are very appreciated
Compiling a GTK4 Rust application on Windows should work fine in theory but there are probably bugs if nobody tried it yet. And I think this is such a bug that you recently introduced @bilelmoussaoui :)
gtk_printer_is_paused
and related are from gtk-4.0/unix-print/gtk/gtkprinter.h
and only available on UNIX, not on Windows.
I don't know what the problem with gsk_text_node_has_color_glyphs
though.
I used the regular package from https://packages.msys2.org/package/mingw-w64-x86_64-gtk4, so version 4.1.2. After your question I tried again with an older package and version 4.0.3 with the same errors.
To be honest, I wouldn't even know where to start with this problem.
Compiling a GTK4 Rust application on Windows should work fine in theory but there are probably bugs if nobody tried it yet. And I think this is such a bug that you recently introduced @bilelmoussaoui :)
Would be nice to get a Windows CI for gtk4-rs as well in the future, to avoid such issues :-)
@mmMike Do you mind trying to disable gtk::Printer
, gtk::PrintJob
& gtk::PrintCapabilities
on any platforms other than linux? See https://github.com/gtk-rs/gtk4-rs/blob/master/gtk4/Gir.toml#L1363 on how to do so. After that, you have to run python3 generator.py
to re-generate the bindings.
Mind trying to build from #233 ? :)
Hi, you were faster, but I wouldn't have known how to fix the code parts anyway. However from https://github.com/gtk-rs/gtk4-rs/compare/bilelmoussaoui/printer-win-fix I needed the following diff:
diff --git a/gsk4/src/text_node.rs b/gsk4/src/text_node.rs
index e15835f59..21118f9c3 100644
--- a/gsk4/src/text_node.rs
+++ b/gsk4/src/text_node.rs
@@ -63,6 +63,8 @@ impl TextNode {
unsafe { from_glib_none(ffi::gsk_text_node_get_offset(self.to_glib_none().0)) }
}
+ #[cfg(any(target_os = "linux", feature = "dox"))]
+ #[cfg_attr(feature = "dox", doc(cfg(target_os = "linux")))]
#[doc(alias = "gsk_text_node_has_color_glyphs")]
pub fn has_color_glyphs(&self) -> bool {
unsafe { from_glib(ffi::gsk_text_node_has_color_glyphs(self.to_glib_none().0)) }
diff --git a/gtk4/src/auto/functions.rs b/gtk4/src/auto/functions.rs
index 5679234e1..b894cd9f3 100644
--- a/gtk4/src/auto/functions.rs
+++ b/gtk4/src/auto/functions.rs
@@ -10,7 +10,6 @@ use crate::AccessibleState;
use crate::DebugFlags;
use crate::PageSetup;
use crate::PrintSettings;
-use crate::Printer;
use crate::StyleContext;
use crate::TextDirection;
use crate::TreeModel;
@@ -155,6 +154,8 @@ pub fn disable_setlocale() {
//}
#[doc(alias = "gtk_enumerate_printers")]
+#[cfg(any(target_os = "linux", feature = "dox"))]
+#[cfg_attr(feature = "dox", doc(cfg(target_os = "linux")))]
pub fn enumerate_printers<P: Fn(&Printer) -> bool + Send + Sync + 'static>(func: P, wait: bool) {
assert_initialized_main_thread!();
let func_data: Box_<P> = Box_::new(func);
With that it compiles and runs, just the theme is off, no hidpi scaling and I'm on a 2x display.
I have handled the missing function in the PR as well. No idea why gsk_text_node_has_color_glyphs
is causing issues on windows though.
I checked again, the Gtk3 example respects the scaling to 2x, Gtk4 programs don't on my system, also a C example doesn't respect the scaling.
But at least one step further today. Thank you.
This seems to be the reason why https://github.com/GNOME/gtk/commit/5a8e2a8c2d5a5f41a1135e1890c597ff75b560f1
@sdroege any idea how we should handle it here?
@sdroege any idea how we should handle it here?
That effectively only makes it available in the first release that contains this fix, so that's what you'll have to use as version constraint then.
I checked again, the Gtk3 example respects the scaling to 2x, Gtk4 programs don't on my system, also a C example doesn't respect the scaling.
But at least one step further today. Thank you.
You should be able to build gtk4-rs just fine now. Please report any issues you see in the upstream gtk repository so they get fixed.
Hi,
I'm trying to compile the minimal example (basic.rs) on Windows. I have a clean MSYS2 setup and Rust also via MSYS2. The packages for Freetype, Gtk3 and Gtk4 are installed.
The Gtk3 version of basic.rs works as expected.
The Gtk4 version gives the following problems, all but one releated to printing:
Testing with rust via rustup and MSVC toolchain gives linker errors with missing gobject-2.0.lib (and other *gtk*.lib). The .lib are not in the MSYS2 packages, only .dll and *.dll.a. Rust projects without Gtk work with this toolchain.
Is it already possible to compile a gtk4-rs application on Windows?