Gtk menubar (and gtkglarea) question

I hate to ask this question here, but I’m wondering if this might be a julia gtk issue. Everything I’ve seen says i should simply connect the “activate” signal to the menu item and it should work. but I’m not seeing it work. I’ve included a simple button that does work.

Also, does anybody know if the gtkglarea widget would work through the julia-gtk package ??

code & glade file follows, the problem being that selecting file->new doesn’t do anything.

Julia code
glade file

Thanks !

function file_new(w)
    println("File Menu")

You callback didn’t take the widget…

Out of curiosity do you hate asking questions? Or just hate asking here?

Really amazing that I never noticed that, I stared at that code for well over an hour.

however, this little mistake does raise an interesting point, and does make this make my question julia relevant (as opposed to it being more of a gtk related question). it’s actually not obvious to me why the call didn’t work without generating an error.

either the compiler should be disappointed that I didn’t pass in a function that takes a widget argument, or, the dispatch should break since there was no function to call. It seems like some sort of bug that it silently failed.

p.s. lol, no i don’t hate asking questions. I thought this might be a gtk specific question as opposed to a julia specific question, i.e., didn’t really belong here. However, I had seen another post where, in fact, a widget in the Julia gtk interface was not working properly.

p.p.s yes, in fact adding the w argument does fix it. thank you !

I agree with you that this is fricken annoying…I suspect it might be a julia to C library issue. i.e. Julia is just passing a function pointer to the GTK C library, and ultimately the GTK library is calling it back. It appears if the number of parameter are wrong, GTK doesn’t call it, which to me, brings up the question “What did it really call?”, “How did it know the parameters were wrong?”, and “Did this just cause memory corruption?”.

I suspect to fix this issue would require GTK.jl to either verify the callback functions (which I don’t think it possible) or for each notification type provide a “trampoline” function with the correct parameters which then calls “your” function. The trampoline function would keep stuff in the Julia space so Julia could detect the parameter mismatch and report an error.

yeah- those various thoughts crossed my mind too.

I just looked at the Gtk source. It simply takes the julia callback function that you supplied, turns it into a cfunction_, which wraps it into another function (so - i thikn similar to your trampoline idea). The original function just keeps propagating all the way through so it’s not at all obvious why it should not be called, it seems like regardless of the arguments the function should still be invoked. There’s almost certainly something wrong…

However it is obvious why I don’t get a compiler error. The cb is defined as a “Function” without any argument specification at all. so it doesn’t matter if the function takes 0 arguments or 10 arguments, it’s still a function and will satisfy the argument type of “Function”.