Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Connecting event to calendar #673

Closed
rossati opened this issue Oct 27, 2022 · 4 comments
Closed

Connecting event to calendar #673

rossati opened this issue Oct 27, 2022 · 4 comments

Comments

@rossati
Copy link

rossati commented Oct 27, 2022

Hi
I am new on Julia and
I am trying to use the GTK Calendar:

using GTK3_jll 
const libgtk = libgtk3
using Gtk, Gtk.ShortNames
function fnz(x)
    println("$x")
end
win = GtkWindow( "Try Calendar")
c = ccall((:gtk_calendar_new,libgtk), Ptr{GObject}, (Ptr{UInt8},),"")
push!(win,c)
z = showall(win)
return ""

The problem arises when I try to link the day-selected signal to a Julia function:

First attempt

via g_signal_connect function

fnz_c = @cfunction(fnz,Cvoid,(Ref{String},))
ccall((:g_signal_connect,libgtk),Ptr{GObject},(Ptr{GObject},Ptr{GObject},Ptr{Cvoid}),c,"day-selected",fnz_c)

I obtain could not load symbol "g_signal_connect" and I not found where the function is declared.

Second attempt

via gtk.jl signal_connect function

id = signal_connect(fnz, c, "day-selected")

In this case the error is: no method matching signal_connect that I suppose for c is a ::Ptr{GObject} and the function needs ::GObject, but I not know how transform a ::Ptr{GObject} into a ::GObject.
Thanks for any sggestions
Giovanni Rossati

@tknopp
Copy link
Collaborator

tknopp commented Oct 27, 2022

c = convert(GObject, ccall((:gtk_calendar_new,libgtk), Ptr{GObject}, (Ptr{UInt8},),""))

Or generate the widget with GtkBuilder.

@rossati
Copy link
Author

rossati commented Oct 27, 2022

Very thank TKnopp
So with GtkBuilder I can easy access to widget non covered by Gtk.jl?

@tknopp
Copy link
Collaborator

tknopp commented Oct 27, 2022

exectly. They will be considered to be GtkWidget and with that you can do already quite a lot.

@rossati
Copy link
Author

rossati commented Oct 27, 2022

I tried, it works very well with file created by Glade, but the GtkBulder by the same string of file doesn't works.
My be is an old problem because i seen an unanswered request on StackOwerflow.

@rossati rossati closed this as completed Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants