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