Sign up

MenuBar taking up all space

I am in progress of learning GTK+, and maybe using GTKD might not be the best way to do it, but it'll have to do. My error here is probably extremely stupid but I really couldn't figure it out.

When I create a MenuBar, it takes up all height available.

int main(string[] arguments) {
	Main.init(arguments);
	Window window = new Window("Test");
	window.setDefaultSize(640, 360);

	auto menu = new MenuBar;
	auto menuItem = menu.append("File");
	auto menuItem2 = menu.append("Edit");
	window.add(menu);

	window.showAll();
	window.addOnDelete(toDelegate(&handleCloseRequested));
	Main.run();

	return 0;
}

How to fix this?

Image Generated Window

Re: MenuBar taking up all space

My example image markdown apparently didn't get parsed properly (or I messed up), here is a link:

http://picpaste.com/pics/3df2fd8389677cc385658858cbd6c925.1394234583.png

Re: MenuBar taking up all space

On 03/08/2014 12:24 AM, Jeroen Bollen wrote:

I am in progress of learning GTK+, and maybe using GTKD might not be the best way to do it, but it'll have to do. My error here is probably extremely stupid but I really couldn't figure it out.

When I create a MenuBar, it takes up all height available.

To get more control of how things are laid out you'll want to wrap thins
in a gtk.Box or gtl.Grid.

int main(string[] arguments) {
	Main.init(arguments);
	Window window = new Window("Test");
	window.setDefaultSize(640, 360);

	auto menu = new MenuBar;
	auto menuItem = menu.append("File");
	auto menuItem2 = menu.append("Edit");

//window.add(menu);

auto vbox = new Box(GtkOrientation.VERTICAL);
// Setting both expand and fill to false, so the extra
// space isn't used by the menu.
vbox.packStart(menu, false, false, 0);
window.add(vbox);

window.showAll();
window.addOnDelete(toDelegate(&handleCloseRequested));
Main.run();

return 0;

}

How to fix this?

Re: MenuBar taking up all space

On Sat, 08 Mar 2014 13:19:10 +0100, Mike Wey wrote:

On 03/08/2014 12:24 AM, Jeroen Bollen wrote:

I am in progress of learning GTK+, and maybe using GTKD might not be the best way to do it, but it'll have to do. My error here is probably extremely stupid but I really couldn't figure it out.

When I create a MenuBar, it takes up all height available.

To get more control of how things are laid out you'll want to wrap thins
in a gtk.Box or gtl.Grid.

int main(string[] arguments) {
	Main.init(arguments);
	Window window = new Window("Test");
	window.setDefaultSize(640, 360);

	auto menu = new MenuBar;
	auto menuItem = menu.append("File");
	auto menuItem2 = menu.append("Edit");

//window.add(menu);

auto vbox = new Box(GtkOrientation.VERTICAL);
// Setting both expand and fill to false, so the extra
// space isn't used by the menu.
vbox.packStart(menu, false, false, 0);
window.add(vbox);

window.showAll();
window.addOnDelete(toDelegate(&handleCloseRequested));
Main.run();

return 0;

}

How to fix this?

Thanks, it did indeed work. Just one little note, new Box(GtkOrientation.VERTICAL); should be new Box(GtkOrientation.VERTICAL, 0);.