This was in response to Martin's code (the following):
object iconwin = GTK.Window( GTK.WINDOW_TOPLEVEL ) ->realize() ->set_title("icon")->add(GTK.Vbox(0,0)->pack_start(GTK.Pixmap(GDK.Pixmap(GDK.Image(0,Image.PNG.decode(Stdio.read_file(rc/pike/gtk/shutdown.png"))))),0,0,0))->get_gdkwindow()->set_icon(GDK.Pixmap(GDK.Image(0,Image.PNG.decode(Stdio.read_file(rc/pike/gtk/shutdown.png")))));
It works as in the reply to Martin, that is, splitting the function calls up. I didn't investigate further, so I don't know how far you have to split the function calls, but I split it all the way.
So, I read in the png file separately, created a bitmap and a pixmap separately, and then created the GTK.Pixmap from the GDK.Pixmap and GDK.Bitmap, then used the GDK.Pixmap and GDK.Bitmap for the set_icon() function, and it worked.
I don't know if this might be a bug somewhere, maybe something gets optimized away? Not sure...
This is with Pike v7.6.66
On Mon, Feb 13, 2006 at 12:31:42PM -0600, lance dillon wrote:
This was in response to Martin's code (the following):
object iconwin = GTK.Window( GTK.WINDOW_TOPLEVEL ) ->realize() ->set_title("icon")->add(GTK.Vbox(0,0)->pack_start(GTK.Pixmap(GDK.Pixmap(GDK.Image(0,Image.PNG.decode(Stdio.read_file(rc/pike/gtk/shutdown.png"))))),0,0,0))->get_gdkwindow()->set_icon(GDK.Pixmap(GDK.Image(0,Image.PNG.decode(Stdio.read_file(rc/pike/gtk/shutdown.png")))));
It works as in the reply to Martin, that is, splitting the function calls up. I didn't investigate further, so I don't know how far you have to split the function calls, but I split it all the way.
So, I read in the png file separately, created a bitmap and a pixmap separately, and then created the GTK.Pixmap from the GDK.Pixmap and GDK.Bitmap, then used the GDK.Pixmap and GDK.Bitmap for the set_icon() function, and it worked.
actually, the splitting up is not what makes it work, but adding a GDK.Bitmap is. i don't do that in my code. (because the docs don't explain how or why that would be needed)
greetings, martin.
On Mon, Feb 13, 2006 at 07:43:40PM +0100, Martin B?hr wrote:
separately, and then created the GTK.Pixmap from the GDK.Pixmap and GDK.Bitmap, then used the GDK.Pixmap and GDK.Bitmap for the set_icon() function, and it worked.
actually, the splitting up is not what makes it work, but adding a GDK.Bitmap is. i don't do that in my code. (because the docs don't explain how or why that would be needed)
there is another difference: vb->pack_start(GTK.Pixmap(px,bmp),0,0,0);
aparently the image needs to be added not only as a GDK.Pixmap to set_icon(), but also as a GTK.Pixmap to the window itself. no idea why that is.
greetings, martin.
there is another difference: vb->pack_start(GTK.Pixmap(px,bmp),0,0,0);
aparently the image needs to be added not only as a GDK.Pixmap to set_icon(), but also as a GTK.Pixmap to the window itself. no idea why that is.
greetings, martin.
No, I just did that because the original code had the icon added to the window also. I just did exactly what the original code did, just split it onto separate lines (and apparently added the bitmap to set_icon() also).
On Mon, Feb 13, 2006 at 01:11:27PM -0600, lance dillon wrote:
No, I just did that because the original code had the icon added to the window also. I just did exactly what the original code did, just split it onto separate lines (and apparently added the bitmap to set_icon() also).
true, but it appears that the icon only works if a object gtkpx=GTK.Pixmap(px,bmp); is created. even it it is not used at all.
greetings, martin.
true, but it appears that the icon only works if a object gtkpx=GTK.Pixmap(px,bmp); is created. even it it is not used at all.
Wow, that is weird. I have no idea why, it doesn't make sense.
Hmm, I also translated the code to c, and it works under c (without the GtkPixmap being created), but not under pike.
I wonder why that is...
You need to keep a reference to the image somewhere. Otherwise it's garbage-collected.
i am not sure. the code works even if i just put GTK.Pixmap(px,bmp); in there. that is, it is not assigned anywhere and should be removed right away.
also, for X to see the image it needs to be moved to the server, where, being an icon, it should remain associated with the window until the client actively replaces it. so garbage collection on the pike side should not influence this.
GTK.Pixmap() does create storage for the image on the server side, and it seems that set_icon() does not although it should.
greetings, martin.
where? shouldn't that reference be removed once it goes out of scope? wouldn't that otherwise cause a leak?
greetings, martin.
where?
In GTK (the GTK.Pixmap object keeps a reference to the GDK.Pixmap object)
shouldn't that reference be removed once it goes out of scope? wouldn't that otherwise cause a leak?
Once the GTK.Pixmap is destroyed it should be removed, yes.
However, there are some peculiarities with the connection between pike and GTK refcouting.
pike-devel@lists.lysator.liu.se