Re: passing on signals
Hi, edscott wilson garcia <[EMAIL PROTECTED]> writes: > I suppose the additional parameter after event will make the call > blocking so that the return value of the signal handler can be > returned there, and if there is no additional parameter (or set to > NULL) the function will just toss the signal on to the queue to be > processed by the event loop and be non-blocking. Just a > hypothesis... Wrong again. GObject signals are always executed synchronously. The g_signal_emit() call returns when all signal handlers have been run. If you pass extra parameters to the g_signal_emit() call you don't change anything. Sven ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: passing on signals
Thanks for the clarification, Sven. I suppose the additional parameter after event will make the call blocking so that the return value of the signal handler can be returned there, and if there is no additional parameter (or set to NULL) the function will just toss the signal on to the queue to be processed by the event loop and be non-blocking. Just a hypothesis... On Thu, 2003-10-02 at 14:04, Sven Neumann wrote: > Hi, > > edscott wilson garcia <[EMAIL PROTECTED]> writes: > > > Does anybody know the correct way to pass on keypressed signals > > received by one widget to another? Either of the following two lines > > causes gtk to segfault when signal received by GtkCombo is passed to > > GtkEntry: > > > > gtk_signal_emit_by_name (GTK_OBJECT (entry), > > "key_press_event",event,data,NULL); > > > > gtk_signal_emit_by_name (GTK_OBJECT (entry), > > "key_press_event",event,data); > > Both lines are wrong. The user_data that is passed to a signal > callback is not set on signal emission but it's the data set when the > signal was connected. The correct code would be: > > gtk_signal_emit_by_name (GTK_OBJECT (entry), "key_press_event", event); > > Actually this is deprecated API, so you would better use the following > instead: > > g_signal_emit_by_name (entry, "key_press_event", event); > > This code assumes that event is a pointer to a GdkEventKey structure. > > > Sven > ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: passing on signals
Hi, edscott wilson garcia <[EMAIL PROTECTED]> writes: > Does anybody know the correct way to pass on keypressed signals > received by one widget to another? Either of the following two lines > causes gtk to segfault when signal received by GtkCombo is passed to > GtkEntry: > > gtk_signal_emit_by_name (GTK_OBJECT (entry), > "key_press_event",event,data,NULL); > > gtk_signal_emit_by_name (GTK_OBJECT (entry), > "key_press_event",event,data); Both lines are wrong. The user_data that is passed to a signal callback is not set on signal emission but it's the data set when the signal was connected. The correct code would be: gtk_signal_emit_by_name (GTK_OBJECT (entry), "key_press_event", event); Actually this is deprecated API, so you would better use the following instead: g_signal_emit_by_name (entry, "key_press_event", event); This code assumes that event is a pointer to a GdkEventKey structure. Sven ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: passing on signals
On Tue, 2003-09-30 at 20:09, edscott wilson garcia wrote: > Hi, > > Does anybody know the correct way to pass on keypressed signals > received by one widget to another? Either of the following two lines > causes gtk to segfault when signal received by GtkCombo is passed to > GtkEntry: > > gtk_signal_emit_by_name (GTK_OBJECT (entry), > "key_press_event",event,data,NULL); > > gtk_signal_emit_by_name (GTK_OBJECT (entry), > "key_press_event",event,data); If anyone is interested, I figured this one out: gtk_signal_emit_by_name() is blocking, i.e. it does not return until the signal has been duly received and processed by the target widget's signal handler. And the value of "data" is overwritten by the return of the signal handler (in this case it returns a guint). This means that you must save whatever you have in "data" to restore it after the function returns. But the fact that gtk_signal_emit_by_name() is blocking means that you have to get into the thread business if you want to make things work as with signal queue. So you are much better off calling the signal handler of the signalled widget directly. Oh well... Edscott > > > TIA, > > Edscott Wilson Garcia > > > > > > ___ > gtk-list mailing list > [EMAIL PROTECTED] > http://mail.gnome.org/mailman/listinfo/gtk-list > ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
passing on signals
Hi, Does anybody know the correct way to pass on keypressed signals received by one widget to another? Either of the following two lines causes gtk to segfault when signal received by GtkCombo is passed to GtkEntry: gtk_signal_emit_by_name (GTK_OBJECT (entry), "key_press_event",event,data,NULL); gtk_signal_emit_by_name (GTK_OBJECT (entry), "key_press_event",event,data); TIA, Edscott Wilson Garcia ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list