New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utilities functions #140

Merged
merged 2 commits into from Nov 6, 2016

Conversation

Projects
None yet
4 participants
@GuillaumeGomez
Member

GuillaumeGomez commented Nov 4, 2016

cc @gkoz @EPashkin

@jo: It should fulfill your needs.

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

@GuillaumeGomez awesome!

How can I test this? Would it be enough to point to this branch from Cargo.toml?

Thank you so much.

jo commented Nov 4, 2016

@GuillaumeGomez awesome!

How can I test this? Would it be enough to point to this branch from Cargo.toml?

Thank you so much.

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 4, 2016

Member

When merged, you can just put the glib dependency like this:

glib = { git = "https://github.com/gtk-rs/glib" }

To test it, you have to make it point to my own repo:

glib = { git = "https://github.com/guillaumegomez/glib", branch = "missing_functions" }
Member

GuillaumeGomez commented Nov 4, 2016

When merged, you can just put the glib dependency like this:

glib = { git = "https://github.com/gtk-rs/glib" }

To test it, you have to make it point to my own repo:

glib = { git = "https://github.com/guillaumegomez/glib", branch = "missing_functions" }
@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

I get an error:

[jo@jolap simple-gtk-application]$ cargo run
    Updating git repository `https://github.com/guillaumegomez/glib`
    Updating git repository `https://github.com/gtk-rs/sys`
error: native library `glib` is being linked to by more than one package, and can only be linked to by one package

  glib-sys v0.3.1
  glib-sys v0.3.1 (https://github.com/gtk-rs/sys#774929a2)

jo commented Nov 4, 2016

I get an error:

[jo@jolap simple-gtk-application]$ cargo run
    Updating git repository `https://github.com/guillaumegomez/glib`
    Updating git repository `https://github.com/gtk-rs/sys`
error: native library `glib` is being linked to by more than one package, and can only be linked to by one package

  glib-sys v0.3.1
  glib-sys v0.3.1 (https://github.com/gtk-rs/sys#774929a2)
@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

My Cargo.toml looks like this:

[package]
name = "simple-gtk-application"
version = "0.1.0"
authors = ["Johannes J. Schmidt <jo@die-tf.de>"]

[dependencies]
glib = { git = "https://github.com/guillaumegomez/glib", branch = "missing_functions" }
gio = "0.1.0"
hyper = "0.9.10"
serde = "0.8"
serde_json = "0.8"
serde_derive = "0.8"

[dependencies.gtk]
version = "0.1.0"
features = ["v3_12"]

jo commented Nov 4, 2016

My Cargo.toml looks like this:

[package]
name = "simple-gtk-application"
version = "0.1.0"
authors = ["Johannes J. Schmidt <jo@die-tf.de>"]

[dependencies]
glib = { git = "https://github.com/guillaumegomez/glib", branch = "missing_functions" }
gio = "0.1.0"
hyper = "0.9.10"
serde = "0.8"
serde_json = "0.8"
serde_derive = "0.8"

[dependencies.gtk]
version = "0.1.0"
features = ["v3_12"]
@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

Should I point the other gtk-rs deps to git#master?

jo commented Nov 4, 2016

Should I point the other gtk-rs deps to git#master?

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 4, 2016

Member

Hum... I think it's because of gtk. Just fork our gtk and update its glib dependency like I showed you and then put your gtk dependency on your repo.

Sorry to have you put through this. :-/

Member

GuillaumeGomez commented Nov 4, 2016

Hum... I think it's because of gtk. Just fork our gtk and update its glib dependency like I showed you and then put your gtk dependency on your repo.

Sorry to have you put through this. :-/

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 4, 2016

Member

You don't use gtk? Well, what I said for gtk is still valid for gio.

Member

GuillaumeGomez commented Nov 4, 2016

You don't use gtk? Well, what I said for gtk is still valid for gio.

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

No worry, I am so happy you help!

Yes, I do use gtk, look at the last section of my Cargo. Do I also need to for gio?

jo commented Nov 4, 2016

No worry, I am so happy you help!

Yes, I do use gtk, look at the last section of my Cargo. Do I also need to for gio?

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

Oh, the problems continue:

[jo@jolap gtk]$ cargo build
    Updating git repository `https://github.com/gtk-rs/sys`
    ...

error[E0432]: unresolved import `glib::signal::Inhibit`
 --> src/signal.rs:8:9
  |
8 | pub use glib::signal::Inhibit;
  |         ^^^^^^^^^^^^^^^^^^^^^ no `Inhibit` in `glib::signal`

jo commented Nov 4, 2016

Oh, the problems continue:

[jo@jolap gtk]$ cargo build
    Updating git repository `https://github.com/gtk-rs/sys`
    ...

error[E0432]: unresolved import `glib::signal::Inhibit`
 --> src/signal.rs:8:9
  |
8 | pub use glib::signal::Inhibit;
  |         ^^^^^^^^^^^^^^^^^^^^^ no `Inhibit` in `glib::signal`
@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

Those cross repository dependencies are always a pain. I know this from node so well :(

jo commented Nov 4, 2016

Those cross repository dependencies are always a pain. I know this from node so well :(

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 4, 2016

Member

Sorry, my branch wasn't up-to-date with master. Refresh and retry.

Member

GuillaumeGomez commented Nov 4, 2016

Sorry, my branch wasn't up-to-date with master. Refresh and retry.

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 4, 2016

How do I refresh? I deleted target directory and run cargo build again but still get the same errors

jo commented Nov 4, 2016

How do I refresh? I deleted target directory and run cargo build again but still get the same errors

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 5, 2016

This is my fork of gtk: https://github.com/jo/gtk
I did the following changes:

[jo@jolap gtk]$ git diff
diff --git a/Cargo.toml b/Cargo.toml
index f3d959c..1f39a68 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -71,8 +71,11 @@ git = "https://github.com/gtk-rs/gio"
 version = "0.1.0"

 [dependencies.glib]
-git = "https://github.com/gtk-rs/glib"
-version = "0.1.0"
+# git = "https://github.com/gtk-rs/glib"
+# version = "0.1.0"
+git = "https://github.com/guillaumegomez/glib"
+branch = "missing_functions"
+

 [dependencies.gdk]
 git = "https://github.com/gtk-rs/gdk"

jo commented Nov 5, 2016

This is my fork of gtk: https://github.com/jo/gtk
I did the following changes:

[jo@jolap gtk]$ git diff
diff --git a/Cargo.toml b/Cargo.toml
index f3d959c..1f39a68 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -71,8 +71,11 @@ git = "https://github.com/gtk-rs/gio"
 version = "0.1.0"

 [dependencies.glib]
-git = "https://github.com/gtk-rs/glib"
-version = "0.1.0"
+# git = "https://github.com/gtk-rs/glib"
+# version = "0.1.0"
+git = "https://github.com/guillaumegomez/glib"
+branch = "missing_functions"
+

 [dependencies.gdk]
 git = "https://github.com/gtk-rs/gdk"
@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

It should be ok now, no?

Member

GuillaumeGomez commented Nov 5, 2016

It should be ok now, no?

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 5, 2016

no :(
Maybe Cargo did not update the git checkout of your branch? How can I enforce this?

jo commented Nov 5, 2016

no :(
Maybe Cargo did not update the git checkout of your branch? How can I enforce this?

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

Well, it's not convenient to try to explain. So for now, please clone the repo locally and replace glib dependencies with glib = { path = "../glib" } (if glib and gtk are at the same level). Then from your project, replace gtk dependency with gtk = { path = "../gtk" } (if gtk is at the same level than your project).

I hope it'll make things easier while we wait this PR to get merged.

PS: for glib, don't forget to git checkout missing_functions!

Member

GuillaumeGomez commented Nov 5, 2016

Well, it's not convenient to try to explain. So for now, please clone the repo locally and replace glib dependencies with glib = { path = "../glib" } (if glib and gtk are at the same level). Then from your project, replace gtk dependency with gtk = { path = "../gtk" } (if gtk is at the same level than your project).

I hope it'll make things easier while we wait this PR to get merged.

PS: for glib, don't forget to git checkout missing_functions!

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 5, 2016

OK, will try this during the next days.
Now I learned how to use local dependencies, thank you so much!

jo commented Nov 5, 2016

OK, will try this during the next days.
Now I learned how to use local dependencies, thank you so much!

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

No problem. Like I said, once merged, you won't have to trouble yourself with all this.

Member

GuillaumeGomez commented Nov 5, 2016

No problem. Like I said, once merged, you won't have to trouble yourself with all this.

UserDirectory::PublicShare => ffi::G_USER_DIRECTORY_PUBLIC_SHARE,
UserDirectory::Templates => ffi::G_USER_DIRECTORY_TEMPLATES,
UserDirectory::Videos => ffi::G_USER_DIRECTORY_VIDEOS,
UserDirectory::NDirectories => ffi::G_USER_N_DIRECTORIES,

This comment has been minimized.

@EPashkin

EPashkin Nov 5, 2016

Member

We really need this case in manual code?

@EPashkin

EPashkin Nov 5, 2016

Member

We really need this case in manual code?

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

Well, it's part of the enum so yes.

@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

Well, it's part of the enum so yes.

This comment has been minimized.

@EPashkin

EPashkin Nov 5, 2016

Member

And why also don't remove (comment) in enum?

@EPashkin

EPashkin Nov 5, 2016

Member

And why also don't remove (comment) in enum?

UserDirectory::NDirectories => ffi::G_USER_N_DIRECTORIES,
}
}
}

This comment has been minimized.

@EPashkin

EPashkin Nov 5, 2016

Member

Empty line at end pls.

@EPashkin

EPashkin Nov 5, 2016

Member

Empty line at end pls.

Show outdated Hide outdated src/utils.rs
Show outdated Hide outdated src/utils.rs
Show outdated Hide outdated src/utils.rs
Show outdated Hide outdated src/utils.rs
Show outdated Hide outdated src/utils.rs
@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

Updated.

Member

GuillaumeGomez commented Nov 5, 2016

Updated.

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

Should be good now.

Member

GuillaumeGomez commented Nov 5, 2016

Should be good now.

@EPashkin

This comment has been minimized.

Show comment
Hide comment
@EPashkin

EPashkin Nov 5, 2016

Member

👍
But I still not like NDirectories in rust code.

Member

EPashkin commented Nov 5, 2016

👍
But I still not like NDirectories in rust code.

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 5, 2016

Member

Me neither but it doesn't harm to have it so...

Member

GuillaumeGomez commented Nov 5, 2016

Me neither but it doesn't harm to have it so...

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 6, 2016

@GuillaumeGomez I give up trying to compile gtk-rs packages with local dependencies. I ended up with clones of cairo, gdk, gdk-pixbuf, gio, glib, gtk, pango and sys, used path references everywhere but I get the error:

[jo@jolap gdk]$ cargo build
error: native library `cairo` is being linked to by more than one package, and can only be linked to by one package

  cairo-sys-rs v0.3.1 (https://github.com/gtk-rs/cairo#4a61ff90)
  cairo-sys-rs v0.3.1 (file:///home/jo/github/gtk-rs/cairo/cairo-sys-rs)

This error does not tell me where it happens :/

I will wait for this pr to get landed. Its not urgent for me anyway, I just wanted to contribute my testing. Although its interesting how the libs work together.

jo commented Nov 6, 2016

@GuillaumeGomez I give up trying to compile gtk-rs packages with local dependencies. I ended up with clones of cairo, gdk, gdk-pixbuf, gio, glib, gtk, pango and sys, used path references everywhere but I get the error:

[jo@jolap gdk]$ cargo build
error: native library `cairo` is being linked to by more than one package, and can only be linked to by one package

  cairo-sys-rs v0.3.1 (https://github.com/gtk-rs/cairo#4a61ff90)
  cairo-sys-rs v0.3.1 (file:///home/jo/github/gtk-rs/cairo/cairo-sys-rs)

This error does not tell me where it happens :/

I will wait for this pr to get landed. Its not urgent for me anyway, I just wanted to contribute my testing. Although its interesting how the libs work together.

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 6, 2016

Member

I'll merge it for now. If we encounter issues, we'll just update.

Member

GuillaumeGomez commented Nov 6, 2016

I'll merge it for now. If we encounter issues, we'll just update.

@GuillaumeGomez GuillaumeGomez merged commit 768a969 into gtk-rs:master Nov 6, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@GuillaumeGomez GuillaumeGomez deleted the GuillaumeGomez:missing_functions branch Nov 6, 2016

@jo

This comment has been minimized.

Show comment
Hide comment
@jo

jo Nov 6, 2016

\o/ it works: when I now set

glib::utils::set_program_name(Some("Simple Gtk App"));

it shows the name in the menubar:
bildschirmfoto vom 2016-11-06 11-52-40

Without set_program_name it just displays a dot:
bildschirmfoto vom 2016-11-06 11-56-54

Thank you so much for your work on gtk-rs!

jo commented Nov 6, 2016

\o/ it works: when I now set

glib::utils::set_program_name(Some("Simple Gtk App"));

it shows the name in the menubar:
bildschirmfoto vom 2016-11-06 11-52-40

Without set_program_name it just displays a dot:
bildschirmfoto vom 2016-11-06 11-56-54

Thank you so much for your work on gtk-rs!

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 6, 2016

Member

Great!

Member

GuillaumeGomez commented Nov 6, 2016

Great!

@gkoz

This comment has been minimized.

Show comment
Hide comment
@gkoz

gkoz Nov 8, 2016

Member

I'd recommend removing anything that's already available via std::env, std::fs, std::net. GLib makes sense as a standard library for C, but not for Rust.

Member

gkoz commented Nov 8, 2016

I'd recommend removing anything that's already available via std::env, std::fs, std::net. GLib makes sense as a standard library for C, but not for Rust.

sdroege pushed a commit to sdroege/glib-rs that referenced this pull request Sep 14, 2018

Merge pull request #140 from EPashkin/error_domain_quark
Generate glib::Quark based ErrorDomain for enums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment