-
Notifications
You must be signed in to change notification settings - Fork 35
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
[Help] How to use headerbar? How Gtk classes are translated into swift? #12
Comments
A better inspection of the source code and I found that these classes are implemented in the Sources directory. How would you recommend to approach creating a new one? Where you get the API or the methods that one should implement in the class source? I suppose those are the C Gtk methods, right? |
I am away from a computer for a few days. Once I am back I will give you some information. |
So... First, you need to find documentation for API that you want to use. In your case it is https://developer.gnome.org/gtk3/stable/GtkHeaderBar.html Here you see all properties and methods that are available. To use them you need to create a new class and properties and methods for everything that you find the documentation. I went ahead and created the binding for you so you can see how you would do it, And you can use it in the following way. let headerBar = HeaderBar()
headerBar.title = "Hello World"
headerBar.subtitle = "oh yea"
headerBar.showCloseButton = true
headerBar.spacing = 50
let label = Label(text: "1")
headerBar.packStart(child: label)
headerBar.packStart(child: Label(text: "2"))
headerBar.remove(label)
window.titlebar = headerBar
window.hideTitlebarWhenMaximized = true I hope, it helps. 😄 |
Thank you very much! I will contribute as soon as possible. Why don't you add this instruction into the README so others can get right at it? |
I have found a problem in the new code, the error is (I switched to Ubuntu):
The code I used was:
|
I see I will look into it. |
@TomasLinhart , nevermind, for some reason swift builder is not pulling the new files. I added UnsafePointerGChar and Window.swift; the issue was resolved. Sorry for the bother. |
Not related to your package, but I am doing something wrong. Perhaps @bmdelacruz can also help. Any changes to main.swift requires .build folder to be deleted and the addition to the new files Thank you. |
Found the solution for that too, the contents of Packages.swift:
|
Dear Tomas, You should probably re-release the version with HeaderBar, the sourcefile is not in the assets for 0.3.1. Best, Luis |
Dear Tomas,
Thank you for this bindings! This is super useful.
I have a little experience in Vala, but on trying to use some elements from gtk I get errors. Specifically I am trying to use headerbars. How do this class translates into Swift? What am I doing wrong in the code below?
The text was updated successfully, but these errors were encountered: