Sign up

Change the main window icon

Hi all. i'm a very newbie in Gtkd...
I'm looking for replace the actual icon off all the gtkd windows
by a personal icon (like myIcon.ico , myIcon.bmp , myIcon.png) .

someone to help me please ?
(librairies wich must be imported - syntax - little example of script)
Very thanks.

Re: Change the main window icon

On Wed, 09 Oct 2019 16:32:38 GMT, peter pinkness wrote:

Hi all. i'm a very newbie in Gtkd...
I'm looking for replace the actual icon off all the gtkd windows
by a personal icon (like myIcon.ico , myIcon.bmp , myIcon.png) .

someone to help me please ?
(librairies wich must be imported - syntax - little example of script)
Very thanks.

Hi Peter,

Mike's away, so I whipped up a quick demo (which will now, eventually, go on my blog as well). It's not too difficult, just a call to setIconFromFile() as you can see in the TestRigWindow class:

// Description of example

import std.stdio;

import gtk.MainWindow;
import gtk.Main;
import gtk.Box;
import gtk.Widget;

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

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


class TestRigWindow : MainWindow
{
	string title = "<Insert Title>";
	AppBox appBox;
	
	this()
	{
		super(title);
		setIconFromFile("images/road_crew.png");
		addOnDestroy(&quitApp);
		
		appBox = new AppBox();
		add(appBox);
		
		showAll();

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

} // class TestRigWindow


class AppBox : Box
{
	bool expand = false, fill = false;
	uint globalPadding = 10, localPadding = 5;
	// add child object and variable definitions here
	
	this()
	{
		super(Orientation.VERTICAL, globalPadding);
		
		// instantiate child objects here
		
		// packStart(<child object>, expand, fill, localPadding); // LEFT justify
		// packEnd(<child object>, expand, fill, localPadding); // RIGHT justify
		
	} // this()

} // class AppBox

And if you're just getting into all this, you might like to check out the blog I mentioned: GtkDcoding.

Re: Change the main window icon

On Wed, 09 Oct 2019 18:32:46 GMT, Ron Tarrant wrote:

Mike's away, so I whipped up a quick demo (which will now, eventually, go on my blog as well). It's not too difficult, just a call to setIconFromFile() as you can see in the TestRigWindow class:

I forgot to mention...

You'll have to provide your own image file. The one I used here is 35 x 35 pixels. Just make sure the path is correct, and you'll be in business.

Also, you'll note that the directory/folder separator is the '/' instead of the Windows separator ''. Internally, D makes allowances for the different slashes. Either works, no matter if you're on Windows, Linux, another UNIX-alike, Mac, what-have-you.

And welcome to GtkD.

Re: Change the main window icon

Thanks for your Welcome, and your answer ! (from France...) :)

Have you a link, to show it or a short script example ? ( hi hi : a kind of "hello world" with the new icon)
Me, at the same time, i will soon looking for in the web, this function " setIconFromFile() " ;-)
In fact, i'm not (yet...) an OOP user (very noob, i say ;-) )

Regards.

Re: Change the main window icon

Ooops, sorry, I had not seen the first message up yet ... (I just woke up!)
It's very clear, thanks again for your responsiveness :)

Re: Change the main window icon

On Thu, 10 Oct 2019 05:38:31 GMT, peter pinkness wrote:

Ooops, sorry, I had not seen the first message up yet ... (I just woke up!)

No worries. I wake up from time to time, too. :)

It's very clear, thanks again for your responsiveness :)

You're welcome, Peter. Hope you enjoy the GtkDcoding blog.