View previous topic :: View next topic |
Author |
Message |
Mengu
Joined: 21 Mar 2010 Posts: 21
|
Posted: Mon Apr 12, 2010 12:37 pm Post subject: How to iterate through getChildren |
|
|
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 |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Mon Apr 12, 2010 1:31 pm Post subject: |
|
|
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 |
|
|
Mengu
Joined: 21 Mar 2010 Posts: 21
|
Posted: Mon Apr 12, 2010 1:49 pm Post subject: |
|
|
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.
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 |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Tue Apr 13, 2010 1:51 pm Post subject: |
|
|
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 |
|
|
|