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

How to iterate through getChildren

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



Joined: 21 Mar 2010
Posts: 21

PostPosted: Mon Apr 12, 2010 12:37 pm    Post subject: How to iterate through getChildren Reply with quote

Hi,

I have a Notebook and as my tab labels I have HBox which consists of a Button for closing the notebook tab and Label as the file name. I would like to know how can I access the Label from HBox. How can I iterate through HBox.getChildren()?

Thanks in advance.
_________________
mengu.net - some kind of monster
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Mon Apr 12, 2010 1:31 pm    Post subject: Reply with quote

You could turn the GList into a array of widgets like so:

Code:
ListG list = HBox.getChildren();
Widget[] widgets;

for (int i=0; i < list.length; i++)
{
    widgets ~= new Widget( cast(GtkWidget*)list.nthData(i) );
}


Or use the GList directly.

And there is also Container.foreac.[/code]
Back to top
View user's profile Send private message
Mengu



Joined: 21 Mar 2010
Posts: 21

PostPosted: Mon Apr 12, 2010 1:49 pm    Post subject: Reply with quote

Mike Wey wrote:
You could turn the GList into a array of widgets like so:

Code:
ListG list = HBox.getChildren();
Widget[] widgets;

for (int i=0; i < list.length; i++)
{
    widgets ~= new Widget( cast(GtkWidget*)list.nthData(i) );
}


Or use the GList directly.

And there is also Container.foreac.


Thank you Mike, working perfect as I have expected. I was trying to cast the "data()" to Widget. Could you explain me why I need to cast it to GtkWidget* first?

I have asked this question instead of creating new files, i want to setCurrentPage for Notebook. Smile

thank you for this great tool. my project (a web development ide) is becoming larger and larger. currently around 2000 lines of codes.
_________________
mengu.net - some kind of monster
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Tue Apr 13, 2010 1:51 pm    Post subject: Reply with quote

The ListG contains pointers to the C structs, so we first cast it to the correct pointer and then initialize the D class that wraps it.
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