GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Jul 31, 2014 3:33 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Make something happen before a window is destroyed
PostPosted: Sun Aug 19, 2012 12:20 am 
Offline

Joined: Tue Jul 24, 2012 12:06 am
Posts: 4
I have a feeling that I'm missing something obvious here but I just can't wrap my mind around it.

I have connected the "destroy" signal to a widget, but I want to check some other stuff to decide if the widget should be destroyed before actually destroying it. There are several icons within the program that can destroy that particular widget.

My question is, do I have to add something to check if the widget should be destroyed to each of those other icons before issuing the gtk_widget_destroy(), or is there something that I can do to intercept gtk_widget_destroy() before it actually destroys the widget and ask then?

I don't get the destroy signal until after the widget has actually been destroyed, which makes sense but that's not what I want.


Top
 Profile  
 
 Post subject: Re: Make something happen before a window is destroyed
PostPosted: Thu Aug 23, 2012 3:55 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Not too sure I follow.
Firstly the signal connection you mention isn't "to" a widget, but rather "from". I imagine from what you say that you're connecting the destroy signal of a widget to the inbuilt gtk_widget_destroy callback. Your alternative is to connect your own function to this signal which does all the stuff you want and then calls gtk_widget_destroy.
In this case, unless you're using g_signal_connect_after, then I don't see how you would end up capturing the signal after it is destroyed.


Top
 Profile  
 
 Post subject: Re: Make something happen before a window is destroyed
PostPosted: Fri Aug 24, 2012 8:14 pm 
Offline

Joined: Tue Jul 24, 2012 12:06 am
Posts: 4
Lets see if I can do a better job of explaining this (though I've actually ending up doing it in a different way.

Window with stuff.

gtk_widget_destroy(GTK_WINDOW(window);

Signal connected to destroy that says "Do you want to save the stuff in that window?"

The stuff disappeared before the question was asked since the question was attached to the destroy signal, which wasn't emitted until the window was actually destroyed.

I can (and now do) ask if you want to save it before issuing the gtk_widget_destroy command, but thought it might be simpler to grab the destroy signal and ask before proceeding.


Top
 Profile  
 
 Post subject: Re: Make something happen before a window is destroyed
PostPosted: Mon Aug 27, 2012 3:56 pm 
Offline
Familiar Face

Joined: Mon Aug 27, 2012 3:39 pm
Posts: 6
look up the "delete_event" signal. with it, you can preempt that destroy event.

here is a link that discusses it: http://www.gtk.org/tutorial1.2/gtk_tut-2.html


Top
 Profile  
 
 Post subject: Re: Make something happen before a window is destroyed
PostPosted: Mon Aug 27, 2012 6:17 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 734
Location: UK
Hi,

Note the link to the GTK 1.2 example is now very old with many parts of it being deprecated many years ago.

A more up to date link is for GTK+ version 2 below. This should also apply to GTK+ version 3.
http://developer.gnome.org/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group