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

Gtk Notebook Tab Close Button Signals

 
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 Mar 22, 2010 8:22 am    Post subject: Gtk Notebook Tab Close Button Signals Reply with quote

Hi,

I have successfully created a notebook and I can create pages automatically as much as I want and I have added close button to my tabs: http://omploader.org/vM3d3Nw

My question here is, how do I get the tabId when I click to button? http://paste.pocoo.org/show/eQ7oCGtRaeNmxmR6WbWe/ is how I create the button and insert it in a HBox. So when a button is clicked I can get its parent like button.getParent() which is a HBox and since Notebook has HBox as its child widget for the page I thought I could get it like notebook.pageNum(button.getParent()); however this returns -1.

Please let me know how should I do it.
_________________
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 Mar 22, 2010 12:44 pm    Post subject: Reply with quote

I think Gtk doesn't count the tab label as a child of the notebook only the contents.

I'll look into this.
Back to top
View user's profile Send private message
Mengu



Joined: 21 Mar 2010
Posts: 21

PostPosted: Mon Mar 22, 2010 1:16 pm    Post subject: Reply with quote

Mike Wey wrote:
I think Gtk doesn't count the tab label as a child of the notebook only the contents.

I'll look into this.


Thanks Mike.

Actually I have solved this. Smile For future reference for people, let me explain how I did it.

After creating my new tab and saving the page number as int newTabIndex, I have used "setData" method (belongs to ObjectG class) for my tab label button like this: myButton.setData("tabIndex", cast(void*) newTabIndex);

I have attached an "addOnClicked" method to the button and when it is clicked, I get the page number (tabIndex) like this: cast(int)button.getData("tabIndex"). And now I am able to close my notebook tabs. Smile

I hope this helps.

If there is any other way for this, I'd like to hear.
_________________
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 Mar 22, 2010 3:58 pm    Post subject: Reply with quote

That seems to be the way to do it.
Back to top
View user's profile Send private message
Mengu



Joined: 21 Mar 2010
Posts: 21

PostPosted: Mon Mar 22, 2010 4:06 pm    Post subject: Reply with quote

Mike Wey wrote:
That seems to be the way to do it.


however this is a bad practice. it is working very well if i close the tabs from the end, but if i close the tabs from the beginning, since the tabs are re-ordered and got a new page num, it is not working correctly.

i add the textview in a scrolledwindow and i add the scrolled window as the new tab, so after this operation, i saved the data as myButton.saveData("tabWidget", scrolledWindowInstance); so in the click action of myButton i get the page number like this: int pageNum = this.filesTab.pageNum(cast(Widget)btn.getData("tabWidget")); and I close the tab: this.filesTab.removePage(pageNum). this is working very well: http://omploader.org/vM3gyag/out-12.ogv
_________________
mengu.net - some kind of monster
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