View previous topic :: View next topic |
Author |
Message |
nazriel
Joined: 22 Apr 2011 Posts: 4
|
Posted: Fri Apr 22, 2011 2:09 am Post subject: GtkBuilder |
|
|
Greetings.
GtkD 1.4.1 works quite smooth with Gtk+ 2.24.3.
The only problem I've found is support for GtkBuilder.
Loading dynamic UI's when using Libglade works fine without exceptions but it tends to be deprecated and requires extra libs. More flexible in use is GtkBuilder.
I've created simple UI with Glade3, and used such code to run this stuff:
Code: | import gtk.Builder;
import gtk.Main;
import gtk.Window;
import gtk.Widget;
import std.stdio;
import std.c.process;
int main(string[] args)
{
Main.init(args);
Builder b = new Builder;
if ( ! b.addFromFile("bawione.ui") ) {
writefln("Oops, could not create Builder object, check your builder file ;)");
exit(1);
}
Widget w = cast(Widget) b.getObject( "window1" );
b.connectSignals(null);
//writeln(typeid(w)); // also cause segfault
if (w is null)
{
writefln("No window?");
//exit(1);
}
//w.showAll();
Main.run();
return 0;
}
|
I think problem comes with casting
Code: | Widget w = cast(Widget) b.getObject( "window1" ); |
I've tried to make it Window also but result is same.
Object w is null and nothing happens. If I want to do anything with this object, segfaults occurs.
I've compared gtk+ headers and its looks like there are some macros missing. Taken from gtktypes.d
Code: |
/*
* Warning
* GTK_WIDGET_TYPE has been deprecated since version 2.20 and should not be used in newly-written code. Use G_OBJECT_TYPE() instead.
* Gets the type of a widget.
* wid :
* a GtkWidget.
*/
// TODO
// #define GTK_WIDGET_TYPE(wid) (GTK_OBJECT_TYPE (wid))
|
Ofcours its only one example.
What do you guys think?
Is there any way to fix it?
Anyways! Cheers for good job! This is really solid binding around here!
PS. Why there is nobody at IRC? :p |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Mon Apr 25, 2011 8:53 am Post subject: |
|
|
With svn r836 getObject also works with ldc. |
|
Back to top |
|
|
nazriel
Joined: 22 Apr 2011 Posts: 4
|
Posted: Tue Apr 26, 2011 5:33 am Post subject: |
|
|
With dmd 2.052 on
Code: | Linux d3 2.6.38-gentoo-r1 #14 SMP Wed Apr 13 22:09:53 UTC 2011 i686 Intel(R) Core(TM) i5 CPU M 450 @ 2.40GHz GenuineIntel GNU/Linux | works very well.
Good job mate!
Cheers! Cya around |
|
Back to top |
|
|
|