Signals and marshaling



Another question:
        I want that 'Quit' menu item close my application. But I already define
        callback for "delete_event". So put call to this call back into 'Quit'
        menu-item callback:

void
menu_close_cb( GtkWidget* widget,
                   gpointer   data )
{
        delete_event_cb( NULL, NULL );
}

        But this is ugly (am I right?) - I decide to make the following:
        'Quit' menu item should emit "delete_event", which will be traped
        by application and so "delete_event_cb" will be called automaticly
        (self-acting). So:

void
menu_close_cb( GtkWidget* widget,
                   gpointer   data )
{
        /* Parameter 'data' is main_window widget.  */
        gtk_signal_emit_by_name( GTK_OBJECT(data), "delete_event" );

        //delete_event_cb( NULL, NULL );
}

        But this dump core :-[ - something wrong with signal priorities?
        [one signal called during another].

        So to avoid core dump I define my marshaller and call back for menu
        item:

gtk_signal_connect_full( GTK_OBJECT(close_item),
                         "activate",
                         NULL, /* No call-back function at all! */
                         (GtkCallbackMarshal)(delete_event_marshal_NONE__NONE),
                         GTK_WIDGET(main_window),
                         NULL,
                         FALSE,
                         GTK_RUN_FIRST );


void gcp_delete_event_marshal_NONE__NONE(GtkObject *object,
                                    gpointer   data,
                                    guint      n_args,
                                    GtkArg    *args)
{
        gtk_signal_emit_by_name( GTK_OBJECT(data), "delete_event" );
}


        But this core dump too!!!

How can I transform emition of one signal to emition of other signal?
 [or call one signal from another?]

PS. Does "gtk_signal_emit_stop_by_name" stops propagation only for
    for current signal with given name (and NOT all signals with given
    name [may be in future])? If I am right may be I should use
"gtk_signal_emit_stop_by_name"
    to stop one signal propagation and after that emit another signal?
    Something like:
    (I haven't try the following example yet)

void
menu_close_cb( GtkWidget* widget,
                   gpointer   data )
{
        /* Stop current signal propagation.  */
        gtk_signal_emit_stop_by_name( GTK_OBJECT(widget) /* menu item */,
                                                "activate" );

        /* Parameter 'data' is main_window widget.  */
        gtk_signal_emit_by_name( GTK_OBJECT(data), "delete_event" );

        //delete_event_cb( NULL, NULL );
}

---
Dmitry Ponomaryov





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