Re: Help with closing a notebook page (GTK2)



On 04/07/11 04:31, Thomas Bollmeier wrote:
----UrsprÃngliche Nachricht-----
Von: "Neil Munro"<neilmunro gmail com>
Gesendet: 02.07.2011 23:40:02
An: gtk-app-devel-list gnome org
Betreff: Help with closing a notebook page (GTK2)

Hi, I have used pygtk before so I am familiar with some of the basic
concepts of gtk, but this is my first attempt with an actual gtk+ C
application and I have run into a few issues.

I have a notebook that I wish to have a close button on the page tabs
that when clicked closes the tabs.

I know that it's a bit off a faf to do as you don't know the page
prior to the event. So you have to dynamically detect which tab is
being closed by using a tab child widget.

Now I believe I have done this in code, except it always returns -1
which then firmly tells me I have done something wrong.

I have attached the code for your reference in the hopes that someone
shall be able to point out my no doubt simple mistake.

Many thanks in advance,
Neil Munro
I faced a similar problem when I wrote an editor for the first version of my gobjectcreator tool some time 
ago. It was
implemented in PyGTK - nevertheless it should work in C as well. The solution may not be elegant but it
worked:
I registered a handler for the "clicked"-signal of the close button within the tab label widget (a GtkHBox).
Within the handler implementation I looped over all pages of the notebook and checked whether the button 
instance
in the page label was identical to the sender instance of the "clicked"-signal. If yes then I had to remove 
the
corresponding page.
You can find the code example here:

https://github.com/ThomasBollmeier/GObjectCreator/blob/master/gobject_creator/ui/documents_view.py

(see lines 342ff. and 378ff. respectively)

Hope that helps.

Regards,
Thomas



___________________________________________________________
Schon gehÃrt? WEB.DE hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://produkte.web.de/go/toolbar
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Hi Thomas

As you say, "not very elegant"

Recently using pyGtk, hard coding, rather than using IDE. Having used GTK with C in the past, I find pyGtk easier to use than C, but maybe a little less powerful. (Could also be that I am learning Python which is generally faster to code than C). It would be going off topic to mention more about pyGtk being less powerful, and maybe I am wrong because I have problems with Tables which I dont use in my C based code... i.e they might not work as I expect in GTK with C either, so there is no difference

In C your clicked signal can pass the notebook instance back to the click handler. Assume the same can be done with pyGtk, but have not used notebooks with pyGtk yet

Rgds Bill



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]