Sign up

Using Builder and addCallbackSymbol

I try to use glade and builder for creating the UIs.
I struggle with the events defined in glade.

In my UI I have a button with the on click event "onbtnConfigclicked".
My intention is to have in class WindowMain a method
onbtnConfigclicked and I can connect the signal with
this method. I do not know how to achieve this.

As a first try I created the static method onbtnConfigclicked.
The coding compiles but throws an access violation error.

import gtk.Window;
import gtk.Label;
import gtk.Main;
import gtk.Box;
import gtk.ButtonBox;
import gtk.Button;
import gtk.Widget;

import gtk.Builder;

class WindowMain{

	private Window window;

	this(){
		Builder g = new Builder();
		g.addFromFile("wMain.glade");
		this.window = cast(Window)g.getObject("wMain");


		g.addCallbackSymbol("on_btnConfig_clicked", &on_btnConfig_clicked);
		g.connectSignals(null);

		this.window.showAll();
	}
}

extern(C) void on_btnConfig_clicked(){
}

void main(string[] args)
{
	Main.init(args);
	WindowMain w = new WindowMain();
	Main.run();
}

Kind regards
André

Re: Using Builder and addCallbackSymbol

On 11/20/2013 10:12 PM, André wrote:

I try to use glade and builder for creating the UIs.
I struggle with the events defined in glade.

In my UI I have a button with the on click event "onbtnConfigclicked".
My intention is to have in class WindowMain a method
onbtnConfigclicked and I can connect the signal with
this method. I do not know how to achieve this.

As a first try I created the static method onbtnConfigclicked.
The coding compiles but throws an access violation error.

import gtk.Window;
import gtk.Label;
import gtk.Main;
import gtk.Box;
import gtk.ButtonBox;
import gtk.Button;
import gtk.Widget;

import gtk.Builder;

class WindowMain{

	private Window window;

	this(){
		Builder g = new Builder();
		g.addFromFile("wMain.glade");
		this.window = cast(Window)g.getObject("wMain");


		g.addCallbackSymbol("on_btnConfig_clicked", &on_btnConfig_clicked);
		g.connectSignals(null);

		this.window.showAll();
	}
}

extern(C) void on_btnConfig_clicked(){
}

void main(string[] args)
{
	Main.init(args);
	WindowMain w = new WindowMain();
	Main.run();
}

Kind regards
André

Are you using Gtk 3.10 ?

Re: Using Builder and addCallbackSymbol

I use GtkD 2.3.1 with Gtk+ Runtime 3.8 (32 bits).

Kind regards
André

Re: Using Builder and addCallbackSymbol

On 11/22/2013 04:16 PM, André wrote:

I use GtkD 2.3.1 with Gtk+ Runtime 3.8 (32 bits).

Kind regards
André

addCallbackSymbol only works with Gtk+ 3.10 and up.