-
Notifications
You must be signed in to change notification settings - Fork 80
More changes towards getting ImageView running #10
Conversation
GdkEventKey does not contain the current pointer location, so this is needed for handling keypress events whose action depends on the current pointer position.
This also - fixes a library-specification problem in some signal-handling functions - adds tests on signal callbacks
const _gpy = Cint[-1] | ||
const _gpmask = Cint[-1] | ||
function get_pointer(w::GtkWidgetI) | ||
ccall((:gdk_window_get_pointer,libgtk), Ptr{Void}, |
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.
this function is deprecated in Gtk-3
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.
I noticed that. Does that mean it's available until gtk4? Is there a horizon for that?
If we want to avoid using this, it's 4 ccall
s rather than 1. That's no big deal, of course, and will change it if you think we should.
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.
Since deprecated means "do not use in new code", I would rather not provide it to be used at all. All get_
(and set_
) methods should be in GAccessor
, without the get
prefix, since they can be auto-generated.
Is GdkWindow useful from a client level? I can just add it to the GAccessor
list of filter objects.
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.
Since deprecated means "do not use in new code", I would rather not provide it to be used at all.
Fair enough.
Re GAccessor
, I haven't dug into this yet. The only use I have so far for GdkWindow is getting the pointer position. But of course time may encourage me to add more. I can imagine wanting to hide or unhide window in response to a key binding, and a destroyall
---not sure yet what those would require.
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.
Those operations would be done at the GtkWidget level
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.
I might have to ask you to tackle get_pointer
, since I'm not sure I understand how you want to implement this. My use case is the following: Ctrl-Scroll
in ImageView zooms in & out, centered on the current mouse position. To support people who don't have wheel mice, I currently map Ctrl-Up
and Ctrl-Down
to the same zoom operation. Since an EventKey
does not contain the pointer position, I need a mechanism to extract the current position of the pointer in a window.
Don't worry about setting up a merge conflict for me, just go ahead and do it and I'll deal.
I'll close this in favor of #12, since the other two items require more extensive direction from @vtjnash about the right solution. FYI I view the |
The most important of these---and the one that deserves the most careful scrutiny---is the patch adding
connect
. I added it because I was finding it awkward to pass extra data to callbacks. Usage ofconnect
would take either of the following patterns:The latter is used when there is a
GdkEvent
associated with the signal.Overall, I think this is a fairly nice interface, but there are alternatives. Rather than using an anonymous function to store the extra arguments, we could presumably define it as
where
func
gets called asfunc(obj, event, args...)
, and set theargs
tuple as the data argument ofg_signal_connect_data
. However, one problem with that interface is how to handlegconnectflags
. So the anonymous-function interface seemed the better way to go.I should also mention that do find the current
signal_connect
slightly confusing:data
argument is namedclosure
.data
argument is last, aftergconnectflags
, which is presumably a rarely-used option. That propagates toon_signal_button_press
and friends, meaning that most usages of this function might look like this:where
extradata
contains whatever state information the widget callback needs in order to do its job. If one could pass it asthen that argument order might make more sense, but that doesn't work either unless
signal_connect
's function declaration were written in terms ofclosure...
.I suspect I'm simply not understanding how you intended to use it, and perhaps that's part of why I decided to create a wrapper.
The other patches in this PR (so far) should be fairly straightforward, as long as you like the names. The key constants are a bit awkward to use in practice,
which is quite a lot of characters to type in front of the key constant. Though naturally, one can say
and shorten it. (Seemingly, one can't say
using
for abaremodule
.)