jeremyletang / rgtk

GTK+ bindings and wrappers for Rust (DEPRECATED SEE https://github.com/rust-gnome )
GNU Lesser General Public License v3.0
121 stars 22 forks source link

Support the Quartz backend on OS X #161

Closed oakes closed 9 years ago

oakes commented 9 years ago

Fix #2 by mentioning the custom homebrew formula pointed out by @dubcanada. The only fix needed is that GtkSocket needs to be stubbed out because it doesn't look like the Quartz backend supports it. Compiling with this is much better than with X11.

GuillaumeGomez commented 9 years ago

The GtkSocket is only working with X11. You should add compilation conditions for SocketWidget export too. There is no use to provide it on mac if it's not supported on mac (same goes for windows by the way...).

oakes commented 9 years ago

Can I use the cfg attribute to do that?

GuillaumeGomez commented 9 years ago

Yes, just like this:

#[cfg(target_os = "linux")]
// or
#[cfg(target_os = "macos")]

You can even do that:

#[cfg(target_arch="x86_64")]
#[cfg(target_arch="x86")]
oakes commented 9 years ago

How's that?

GuillaumeGomez commented 9 years ago

That's good ! I'll wait that @jeremyletang take a look at it before merging it (or maybe he'll merge it himself).

jeremyletang commented 9 years ago

hey @oakes ! thanks for this PR.

I've used the gtk-osx quartz backend on mac os previously, but on my computer a lot of widgets was not supported and that's make the application ( like gtktest.rs ) crash when using them (e.g Dialogs). Do you have the same behaviour ?

oakes commented 9 years ago

My own app seems to work, which uses FileChooserDialog. However, I just tried the examples and all of them fail with a linker error. I can see from the output that it isn't being passed -L flags to the homebrew directories, so it can't find glib et al. I have no clue why the flags are being passed in my own app but not the example projects.

oakes commented 9 years ago

After deleting my app's Cargo.lock file I get the linker error there as well. I will have to fix this first.

oakes commented 9 years ago

OK I figured it out. The find_library function was failing because it thought I was cross-compiling, and I never saw the error because build.rs was showing the error with println!, which was being consumed by cargo.

I removed the now-obsolete X11 path (pkg-config seems to be fine without setting it at all), and enabled cross-compilation so find_library works. I tested the examples and they all seem to work, including the dialogs in gtktest.

screenshot

GuillaumeGomez commented 9 years ago

I can't check your modifications for the moment, gcc doesn't build on my computer (mint).

Edit: It's good for gcc but not for rgtk :

Compiling rgtk v0.0.1 (file:///home/imperio/rust/rgtk)
Failed to run custom build command for `rgtk v0.0.1 (file:///home/imperio/rust/rgtk)`
Process didn't exit successfully: `/home/imperio/rust/rgtk/target/build/rgtk-d18fcf761e19dee4/build-script-build` (status=101)
--- stdout
cargo:rustc-flags=-L /usr/lib/x86_64-linux-gnu
cargo:rustc-flags=-l gtk-3
cargo:rustc-flags=-l gdk-3
cargo:rustc-flags=-l atk-1.0
cargo:rustc-flags=-l gio-2.0
cargo:rustc-flags=-l pangocairo-1.0
cargo:rustc-flags=-l gdk_pixbuf-2.0
cargo:rustc-flags=-l cairo-gobject
cargo:rustc-flags=-l pango-1.0
cargo:rustc-flags=-l cairo
cargo:rustc-flags=-l gobject-2.0
cargo:rustc-flags=-l glib-2.0

--- stderr
task '<main>' panicked at '`pkg-config '--libs' 'vte-2.90'` did not exit successfully: exit code: 1
--- stderr
Package vte-2.90 was not found in the pkg-config search path.
Perhaps you should add the directory containing `vte-2.90.pc'
to the PKG_CONFIG_PATH environment variable
No package 'vte-2.90' found
', build.rs:40
oakes commented 9 years ago

@GuillaumeGomez it looks like you are trying to use my master branch. That includes a lot of unfinished work I am doing to add support for VteTerminal. You should use my quartz branch instead.

GuillaumeGomez commented 9 years ago

Oh you're right ! My bad... However, the errors remains and is the same one.

oakes commented 9 years ago

You might need to do delete your Cargo.lock file. That's the problem I just had.

GuillaumeGomez commented 9 years ago

Same error.

> rm Cargo.lock
> cargo clean
> cargo update
> cargo build

Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling gcc v0.1.1
   Compiling pkg-config v0.1.1
   Compiling rgtk v0.0.1 (file:///home/imperio/rust/rgtk)
Failed to run custom build command for `rgtk v0.0.1 (file:///home/imperio/rust/rgtk)`
Process didn't exit successfully: `/home/imperio/rust/rgtk/target/build/rgtk-d18fcf761e19dee4/build-script-build` (status=101)
--- stdout
cargo:rustc-flags=-L /usr/lib/x86_64-linux-gnu
cargo:rustc-flags=-l gtk-3
cargo:rustc-flags=-l gdk-3
cargo:rustc-flags=-l atk-1.0
cargo:rustc-flags=-l gio-2.0
cargo:rustc-flags=-l pangocairo-1.0
cargo:rustc-flags=-l gdk_pixbuf-2.0
cargo:rustc-flags=-l cairo-gobject
cargo:rustc-flags=-l pango-1.0
cargo:rustc-flags=-l cairo
cargo:rustc-flags=-l gobject-2.0
cargo:rustc-flags=-l glib-2.0

--- stderr
task '<main>' panicked at '`pkg-config '--libs' 'vte-2.90'` did not exit successfully: exit code: 1
--- stderr
Package vte-2.90 was not found in the pkg-config search path.
Perhaps you should add the directory containing `vte-2.90.pc'
to the PKG_CONFIG_PATH environment variable
No package 'vte-2.90' found
', build.rs:40
oakes commented 9 years ago

Weird, can you check build.rs to see if find_library("vte-2.90") is there? That should only be in my master branch.

GuillaumeGomez commented 9 years ago

You're right, don't how but instead of tracking your quartz branch, I just created a new one locally from master. I confirm it's working. Sorry for that... Is that good for you @jeremyletang ?

jeremyletang commented 9 years ago

hey, @oakes, this seems good for me, I can't test it until sunday, but I think we can merge it for now. Thanks for this stuff it's really cool !