Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:11
    clkamp closed #273
  • 10:11
    clkamp commented #273
  • 10:11
    clkamp edited #273
  • 10:10
    clkamp edited #273
  • 10:10
    clkamp edited #273
  • 10:10
    clkamp edited #273
  • 10:10
    clkamp edited #273
  • 10:09
    clkamp edited #273
  • Feb 18 22:08

    garetxe on gi-gio-2.0.26

    (compare)

  • Feb 18 22:07

    garetxe on master

    Mark the return value of appInf… (compare)

  • Feb 18 22:05
    garetxe commented #276
  • Feb 18 14:14
    phuhl commented #276
  • Feb 18 14:11
    phuhl commented #276
  • Feb 18 14:09
    phuhl edited #276
  • Feb 18 14:08
    phuhl opened #276
  • Feb 17 17:37
    jmazon opened #275
  • Feb 12 15:23
    clkamp edited #273
  • Feb 12 15:21
    clkamp edited #273
  • Feb 09 22:13
    garetxe commented #274
  • Feb 09 22:04
    garetxe commented #274
Andri Möll
@moll
Wow, quick reply, thanks! Let me find out!
It seems to type check. ^_^
My event doesn't seem to work, but that could be that I'm missing some fields.
Thanks!
Iñaki
@garetxe
You're welcome!
Andri Möll
@moll
Btw, Gdk type links seem to be broken on Hackage — https://hackage.haskell.org/package/gi-gtk-3.0.32/docs/GI-Gtk-Objects-Widget.html#v:getWidgetWindow should probably link to GdkWindow.
Want another issue for that? :P
Iñaki
@garetxe
Yep, please! Probably the same as the other one you reported recently (sorry, a bit busy lately), but it won't harm to have it there just in case.
Andri Möll
@moll
No hurry. It's OSS — nothing's stopping me from jumping in and fixing things myself. ^_^
Iñaki
@garetxe
:)
Andri Möll
@moll
One other thing, if I may. http://hackage.haskell.org/package/gi-gdk-3.0.22/docs/GI-Gdk-Structs-EventKey.html#v:setEventKeyWindow takes a Ptr Window. Which of the https://hackage.haskell.org/package/haskell-gi-base-0.23.0/docs/Data-GI-Base-ManagedPtr.html functions seem appropriate to you to get a Ptr out to jam in a Gdk.eventNew? My initial crack went with Gtk.getWidgetWindow widget and passing that to withManagedPtr and then to setEventKeyWindow, but that seems to cause GTK go haywire and delete the widget. :P
I presume that's because GTK frees the associated GdkWindow, but nothing had incremented its use prior to me jamming it to that GdkEventKey struct.
Andri Möll
@moll
I threw a g_object_ref_sink in between the setEventKeyWindow call and it seems to have fixed the premature deletion issue.
It certainly would be better if setEventKeyWindow would take a ManagedPtr and call ref on it itself.
Iñaki
@garetxe
The issue is that you are putting a pointer inside a struct, so the bindings lose track of it, and cannot ensure that there is no leak
Andri Möll
@moll
That looks like an one of those label overflow things. I'm keeping it simple with "plain" functions. :)
Iñaki
@garetxe
So by default we do the safe thing, and ask the person using the bindings to be explicit, by passing the ptr
But :&=says that it is fine to allocate
Andri Möll
@moll
It is a struct, but isn't GTK free-ing all related ref counted fields if one calls its g_object_free or smth on it? I remember seeing the event-copy function mentioning that it increases the ref counts on its members.
Iñaki
@garetxe

That looks like an one of those label overflow things. I'm keeping it simple with "plain" functions. :)

Oh :) Then you need to do something like what you did

Andri Möll
@moll
I suppose technically Haskell GI could ensure no-leaks if it ensured the return value of Gdk.eventNew came with a finalizer that unref-ed the event which in turn would, presumably, unref its fields.
Iñaki
@garetxe

It is a struct, but isn't GTK free-ing all related ref counted fields if one calls its g_object_free or smth on it? I remember seeing the event-copy function mentioning that it increases the ref counts on its members.

Unfortunately haskell-gi cannot know this, from the point of view of the introspection data there is no information saying "this field will be freed when the struct is freed". So we have to play it safe

Andri Möll
@moll
Elsewhere there is referencing introspection? So far Haskell GI seems to know when you ref things. :P
Iñaki
@garetxe

I suppose technically Haskell GI could ensure no-leaks if it ensured the return value of Gdk.eventNew came with a finalizer that unref-ed the event which in turn would, presumably, unref its fields.

Yeah, but this would mean treating GdkEvent specially, and I want to keep my sanity :) Luckily gtk4 fixes this to a large extent, GdkEvent gains accessor functions with well defined memory management.

Elsewhere there is referencing introspection? So far Haskell GI seems to know when you ref things. :P

Yes, the problem is that is is a struct field. Generally we can do things nicely when there is a setter function, but this is not the case (generally) for struct fields

Andri Möll
@moll
Ah, okay, so GdkEvent's fields are derived from structs and not from more informative introspection of setters.
Thanks. Got it.
Iñaki
@garetxe
Right, they are a thin wrapper over setting a pointer. We know the type, so we can help a bit, but we don't know the memory ownership semantics
(Although if you allow yourself to use overloading :&=papers over this complication.)
Andri Möll
@moll
The description accompanying :&=doesn't make much sense to my eyes. O:)
Iñaki
@garetxe
Yeah, I just realized that :D
Could you please file an issue? (Sorry, I don't have access now) This is definitely something to improve in the documentation
Andri Möll
@moll
Sure! I'm aiming for the most-issues-opened on Haskell GI award anyway. :P
Iñaki
@garetxe
:D It's really very helpful, thanks!
chenyulue
@chenyulue
Hi, are there some tutorials about gi-gtk? Except the hackage documents and examples
Andri Möll
@moll
I got a start with the examples in the repository, @chenyulue.
Whoops, you did mention the examples already. :innocent:
For the rest I personally went with general GTK tutorials and just translated the examples to Haskell GI-s style.
Apart from an example or two I'd say it's a better use of everyone's time to write tutorials for the original library in its original language and then separately a few on how to translate from the source language to the bindings' language. :P
chenyulue
@chenyulue
Thanks! @moll Mark Karpov's tutorial is also in my notes. Seems the general GTK tutorials is the only choice for learning haskell GUI programming with GTK+.
Karl Melvan
@kmelvn
trying to capture all key press and key release events on a GtkWindow - can't find the function for setting my handler for "key-press-event" and "key-release-event"?
I'm not using overloading, so something like onWidgetKeyReleaseEvent? can't find it in the docs...
Karl Melvan
@kmelvn
oh, I'm looking at 4.0.1 docs and using 3.0.32 ... oh, there's new version :)
due43
@due43
hello
First time using this forum
I am unclear on ManagedPtr, when do I disown or own an object? I want to be able to lookup windows by name, and figured I needed to store a map from name to weak ref
You see the lookups happen according to user input, so I want to allow that objects they indicate might have been cleaned up by gtk already, and in particular I dont want the fact that I have a name for an object to keep it from getting cleaned up if it's reference count would otherwise drop to 0...
due43
@due43
So I envisioned something like (mp :: Map Text GWeakRef) ... But I don't even know how to create a GWeakRef using haskell
and ManagedPtr's machinery makes me wonder if I can use it as a weakref, by disown/own
due43
@due43
I understand ManagedPtr is like ForeignPtr, but allows finalizers to be toggled on and off.. But I wish the documentation was more clear about what said finalizers do in the bindings, so I understood when I would want to toggle them.