FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GtkBuilder

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
nazriel



Joined: 22 Apr 2011
Posts: 4

PostPosted: Fri Apr 22, 2011 2:09 am    Post subject: GtkBuilder Reply with quote

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! Wink

PS. Why there is nobody at IRC? :p
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Mon Apr 25, 2011 7:28 am    Post subject: Reply with quote

The above should work with svn r833.
You can find a demo that uses it here: http://www.dsource.org/projects/gtkd/browser/trunk/demos/builder

Currently it doesn't work with ldc since it doesn't implement Object.factory.
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Mon Apr 25, 2011 8:53 am    Post subject: Reply with quote

With svn r836 getObject also works with ldc.
Back to top
View user's profile Send private message
nazriel



Joined: 22 Apr 2011
Posts: 4

PostPosted: Tue Apr 26, 2011 5:33 am    Post subject: Reply with quote

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! Very Happy Very Happy

Cheers! Cya around
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group