View previous topic :: View next topic |
Author |
Message |
danielking
Joined: 06 Dec 2008 Posts: 6
|
Posted: Sun Dec 14, 2008 8:34 pm Post subject: Is gtk.builder fully implemented? |
|
|
test.d
Code: | module gtk.HelloWorld;
import tango.io.Stdout;
import gtk.Main;
import gtk.Window;
import gtk.Widget;
import gtk.Button;
import gtk.Builder;
class MainWindow
{
Builder b;
Window w;
this()
{
b = new Builder();
if(b)
{
b.addFromFile("test.xml");
}
}
}
void main(string[] args)
{
Main.init(args);
new MainWindow();
Main.run();
}
|
test.xml:
Code: | <?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.12"/>
<object class="GtkWindow" id="wnd">
<property name="width_request">400</property>
<property name="height_request">300</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="default_width">400</property>
<property name="default_height">300</property>
<child>
<object class="GtkVBox" id="vbox">
<property name="visible">True</property>
<child>
<object class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="icon_size">GTK_ICON_SIZE_MENU</property>
<child>
<object class="GtkToolButton" id="tb_note_new">
<property name="visible">True</property>
<property name="stock_id">gtk-new</property>
<signal name="clicked" handler="on_tb_note_new_clicked"/>
</object>
<packing>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkHPaned" id="hpaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkTreeView" id="tv_tags">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkTreeView" id="tv_notes">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface> |
It's compiled successfully, but throw an exception at runtime.
Code: | glib.GException.GException: Invalid object type `GtkVBox' |
|
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Mon Dec 15, 2008 3:07 pm Post subject: |
|
|
the builder classes are not fully implemented, but what you are doing should work. The Error you are seeing is the one returned by gtk. |
|
Back to top |
|
|
danielking
Joined: 06 Dec 2008 Posts: 6
|
Posted: Mon Dec 15, 2008 6:10 pm Post subject: |
|
|
Mike Wey wrote: | the builder classes are not fully implemented, but what you are doing should work. The Error you are seeing is the one returned by gtk. |
But I use the same xml file with a program written in c language, and it works. |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Thu Dec 18, 2008 1:21 pm Post subject: |
|
|
Odd, since GtkD only passes the filename to gtk. |
|
Back to top |
|
|
bkropf
Joined: 28 Oct 2008 Posts: 6
|
Posted: Mon Dec 22, 2008 3:51 am Post subject: |
|
|
It seems I was able to get the provided example to build and run with no errors by adding the following (pulled from a question on another mailing list http://markmail.org/message/x6lavzyivqqk7n2i):
Code: | void main(string[] args) {
Main.init(args);
scope Window w = new Window("fake");
scope VBox v = new VBox(1, 1);
scope Toolbar t = new Toolbar();
scope ToolButton tb = new ToolButton("open");
scope HPaned hp = new HPaned();
scope TreeView tv = new TreeView();
new MainWindow();
Main.run();
} |
|
|
Back to top |
|
|
|