Re: emitting a signal (deleting a window)
- From: Richard Gipps <rgipps netspace net au>
- To: gtk-app-devel-list gnome org
- Cc: Gus Koppel <gtk spamkiller bytechase cx>
- Subject: Re: emitting a signal (deleting a window)
- Date: Thu, 05 Feb 2004 22:53:14 +0000
Thanks for your reply Gus. I have made sure that the on_File_Exit_activate
() gets
called when I select the menu item. I checked this by calling
gtk_signal_emit_by_name() with "destroy" which worked fine. It is only
when I try the "delete_event" I have problems!? I will try your code
instead - thanks for including that.
Richard.
At 22:27 04/02/04, you wrote:
Richard Gipps wrote:
> I am having trouble making an application close when I use my
> File->Exit menu. I have a File Exit signal handler:
>
> void on_File_Exit_activate(GtkMenuItem* menuitem,GtkWidget* Main_wnd)
> {
> gtk_signal_emit_by_name(GTK_OBJECT(Main_wnd),
> "delete_event");
> }
>
> which I thought would 'send' a delete_event to the main Window which
> has the following signal handlers:
>
> gboolean on_Event_Delete(GtkWidget* widget,GdkEvent* event,gpointer
> user_data){
> if(is_object_created == TRUE) //free memory allocated for the
> CAD object (*object_delete_func_ptr)(network);
> return(FALSE); //do not prevent window from being closed
> (destroyed)}
>
> void on_Event_Destroy(GtkWidget* widget,GdkEvent* event,gpointer
> user_data){
> gtk_main_quit();
> }
>
> This works correctly for the delete_event which is emitted when I
> press the X in the corner of the window, but not using the File->Exit
> menu. Any help would be much appreciated.
I use a different approach. I wrote an own function to delete any
window. It's apparently a bit more low level so presumably slightly
faster. My function not only accepts a GtkWindow but any widget within
the window to be closed. It'll determine the associated window by
itself. You could use this function instead of your
gtk_signal_emit_by_name () call and hopefully it should work.
I assume you have made sure that your on_File_Exit_activate () gets
called at all when you select the menu item?
void window_send_delete_event (GtkWidget *widget) {
GtkWindow *window;
GdkEvent event;
g_assert (widget);
while (widget->parent) {
widget = widget->parent; }
window = (GtkWindow *) widget;
// g_log (LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
// "Sending delete event to window %s",
// gtk_widget_get_name ((GtkWidget *) window));
memset (&event, 0, sizeof (GdkEvent));
event.any.type = GDK_DELETE;
event.any.send_event = TRUE;
event.any.window = ((GtkWidget *) window)->window;
gtk_main_do_event (&event);
}
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]