-
-
Notifications
You must be signed in to change notification settings - Fork 63
Add utilities functions #140
Add utilities functions #140
Conversation
@GuillaumeGomez awesome! How can I test this? Would it be enough to point to this branch from Cargo.toml? Thank you so much. |
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" } |
I get an error:
|
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"] |
Should I point the other gtk-rs deps to git#master? |
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. :-/ |
You don't use gtk? Well, what I said for gtk is still valid for gio. |
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? |
Oh, the problems continue:
|
Those cross repository dependencies are always a pain. I know this from node so well :( |
057feed
to
3bc0661
Compare
Sorry, my branch wasn't up-to-date with master. Refresh and retry. |
How do I refresh? I deleted target directory and run |
This is my fork of gtk: https://github.com/jo/gtk [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" |
It should be ok now, no? |
no :( |
Well, it's not convenient to try to explain. So for now, please clone the repo locally and replace glib dependencies with I hope it'll make things easier while we wait this PR to get merged. PS: for glib, don't forget to |
OK, will try this during the next days. |
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need this case in manual code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's part of the enum so yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And why also don't remove (comment) in enum?
UserDirectory::NDirectories => ffi::G_USER_N_DIRECTORIES, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty line at end pls.
use translate::*; | ||
use UserDirectory; | ||
|
||
pub fn get_application_name() -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
human-readable application name. may return NULL
=> Option<String>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it still String
|
||
pub fn path_get_basename(file_name: &str) -> Option<String> { | ||
unsafe { | ||
from_glib_none(ffi::g_path_get_basename(file_name.to_glib_none().0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns: a newly allocated string containing the last component of the filename.
=> from_glib_full
?
} | ||
} | ||
|
||
pub fn path_get_dirname(file_name: &str) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also from_glib_full
} | ||
} | ||
|
||
pub fn find_program_in_path(program: &str) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also from_glib_full
|
||
pub fn get_environ() -> Vec<String> { | ||
unsafe { | ||
FromGlibPtrContainer::from_glib_none(ffi::g_get_environ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also transfer full
but not sure which case.
3bc0661
to
6b68937
Compare
Updated. |
6b68937
to
ecd090c
Compare
Should be good now. |
👍 |
Me neither but it doesn't harm to have it so... |
@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:
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. |
I'll merge it for now. If we encounter issues, we'll just update. |
Great! |
I'd recommend removing anything that's already available via |
cc @gkoz @EPashkin
@jo: It should fulfill your needs.