Sign up

Proper Args for Window.setIconList()?

I'm back banging on this bit of code that puts together a doubly-linked list of Pixbufs for use as Window icons, etc. I assemble the list, check the integrity of the list and everything seems fine. Then I pass it to Window.setIconList() and get the errors shown below.

Does this function work as intended? Am I assembling the ListG wrong?

string[] images = ["images/airport_25.png",
                   "images/airport_35.png",
		   "images/airport_60.png",
		   "images/airport_100.png"];

ListG listG = new ListG(null);
		
for(int i; i < images.length; i++)
{
	string imageName = images[i];
	Pixbuf pixbuf = new Pixbuf(imageName);
	listG = listG.append(cast(void*)pixbuf);
}

// check list integrity
uint listLength = listG.length();
		
for(int i; i < listLength; i++)
{
	Pixbuf pixbuf = cast(Pixbuf)listG.nthData(i);
	writeln("data: ", listG.nthData(i), ", width: ", pixbuf.getWidth());
}

setIconList(listG);

Which results in these errors:

(pixbuf_listg_pixbufs.exe:780): GLib-GObject-CRITICAL **: 15:15:46.141: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(pixbuf_listg_pixbufs.exe:780): GLib-GObject-CRITICAL **: 15:15:46.152: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(pixbuf_listg_pixbufs.exe:780): GLib-GObject-CRITICAL **: 15:15:46.158: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(pixbuf_listg_pixbufs.exe:780): GLib-GObject-CRITICAL **: 15:15:46.165: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
icon list set

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.395: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.400: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.407: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.413: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.419: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.427: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.432: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.439: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.445: gdk_pixbuf_get_has_alpha: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.450: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.457: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): Gdk-WARNING **: 15:15:46.465: gdkcursor-win32.c:1072: CreateDIBSection failed with code 87: The parameter is incorrect.

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.471: gdk_pixbuf_get_has_alpha: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.477: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): GdkPixbuf-CRITICAL **: 15:15:46.482: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(pixbuf_listg_pixbufs.exe:780): Gdk-WARNING **: 15:15:46.490: gdkcursor-win32.c:1072: CreateDIBSection failed with code 87: The parameter is incorrect.

Re: Proper Args for Window.setIconList()?

On 12-11-2019 21:20, Ron Tarrant wrote:

I'm back banging on this bit of code that puts together a doubly-linked list of Pixbufs for use as Window icons, etc. I assemble the list, check the integrity of the list and everything seems fine. Then I pass it to Window.setIconList() and get the errors shown below.

Does this function work as intended? Am I assembling the ListG wrong?

string[] images = ["images/airport_25.png",
                    "images/airport_35.png",
		   "images/airport_60.png",
		   "images/airport_100.png"];

ListG listG = new ListG(null);
		
for(int i; i < images.length; i++)
{
	string imageName = images[i];
	Pixbuf pixbuf = new Pixbuf(imageName);
	listG = listG.append(cast(void*)pixbuf);
}

// check list integrity
uint listLength = listG.length();
		
for(int i; i < listLength; i++)
{
	Pixbuf pixbuf = cast(Pixbuf)listG.nthData(i);
	writeln("data: ", listG.nthData(i), ", width: ", pixbuf.getWidth());
}

setIconList(listG);

This is where binding break down a little and setIconList expects a
linked list of the C structs.

Try changing this line:

listG = listG.append(cast(void*)pixbuf);

To:

listG = listG.append(cast(void*)pixbuf.getPixbufStruct());

Re: Proper Args for Window.setIconList()?

On Tue, 12 Nov 2019 23:28:50 +0100, Mike Wey wrote:

This is where binding break down a little and setIconList expects a
linked list of the C structs.

Try changing this line:

listG = listG.append(cast(void*)pixbuf);

To:

listG = listG.append(cast(void*)pixbuf.getPixbufStruct());

Well, I don't feel so much like this is all getting away from me, now. Thanks for that.

However... that got rid of the warnings, but now the window doesn't open. :)

I'll keep tinkering with it and look into how to go about building a linked list of C structs in D. At least now I know what problem I'm trying to solve.

I'll also post the full code in case you have time to play with it. The images are on GitHub if you need to go so far as to compile and test.

// Put an icon in the titlebar from a Pixbuf.

import std.stdio;

import gtk.MainWindow;
import gtk.Main;
import gtk.Box;
import gtk.Widget;
import gdk.Pixbuf;
import gtk.DrawingArea;

import gdk.Cairo;
import cairo.Context;

import glib.ListG;
import gobject.ObjectG;

void main(string[] args)
{
	TestRigWindow testRigWindow;
	
	Main.init(args);

	testRigWindow = new TestRigWindow();
	
	Main.run();
	
} // main()


class TestRigWindow : MainWindow
{
	string title = "Pixbuf Titlebar Icon";
	Pixbuf airportImage;
	
	this()
	{
		super(title);
		setSizeRequest(640, 480);

		// alternate way to use a titlebar icon
		string[] images = ["images/airport_25.png", "images/airport_35.png", "images/airport_60.png", "images/airport_100.png"];
		ListG listG = new ListG(null);
		
		for(int i; i < images.length; i++)
		{
			string imageName = images[i];
			Pixbuf pixbuf = new Pixbuf(imageName);
//			listG = listG.append(cast(void*)pixbuf);
//			listG = listG.append(cast(void*)pixbuf.getPixbufStruct());
		}

writeln("\n\n");
		// check list integrity
		uint listLength = listG.length();
		
		for(int i; i < listLength; i++)
		{
			Pixbuf pixbuf = cast(Pixbuf)listG.nthData(i);
			writeln("data: ", listG.nthData(i), ", width: ", pixbuf.getWidth());
			
		}

writeln("list integrity seems intact.");
		setIconList(listG);
writeln("icon list set");
		addOnDestroy(&quitApp);
		
		showAll();

	} // this()
	
		
	void quitApp(Widget widget)
	{
		string exitMessage = "Bye.";
		
		writeln(exitMessage);
		
		Main.quit();
		
	} // quitApp()

} // class TestRigWindow

Re: Proper Args for Window.setIconList()?

Since we now have the C structs in the linked list this line is no
longer correct:

Pixbuf pixbuf = cast(Pixbuf)listG.nthData(i);

It should be:

Pixbuf pixbuf = new Pixbuf(cast(GdkPixbuf*)listG.nthData(i));

Re: Proper Args for Window.setIconList()?

On Wed, 13 Nov 2019 23:23:16 +0100, Mike Wey wrote:

Pixbuf pixbuf = cast(Pixbuf)listG.nthData(i);

It should be:

Pixbuf pixbuf = new Pixbuf(cast(GdkPixbuf*)listG.nthData(i));

Hmmm... that doesn't look right, Mike. In fact, I tried it, and it spit out more warnings.

Also, this is the test which doesn't have any bearing on how the structs are put together.

I'm not getting anywhere with this either and I'm just about to give it up as a lost cause.

But thanks for playing.