[Glade-users] How to block some input in GtkEntry field

Quoting Arthur Shats <ashats at hotmail.com>:

So I am blocking the call to gtk_editable_insert_text ? Who/where   
does it print on the screen then if we are blocking _insert_text?   
Also, why do we need g_signal_stop_emission_by_name then?

No you're blocking your own callback handler, which is function  
insert_text_handler() in the example you've cited. Any other functions  
connected to this signal ain't blocked and will be executed in regular  
order. Basically what you're doing is catching the call to  
gtk_editable_insert_text() initiated somewhere else in the code  
(likely the system code, but it can be called by your program in some  
other function too), issuing brand new sequence by calling  
gtk_editable_insert_text() with your own string (*result) as the  
argument, making sure that it would be executed as if your own handler  
did not exist by blocking it, and then stopping the original sequence  
from being finished, so the original string (*text) will be ignored  
instead of being inserted after you've already inserted its modified  
version (*result).

If it's unclear, try to experiment and you'll see what happens, but at  
the end if you omit blocking you should get segfault when stack will  
be overflown, and if you omit stopping emission, you should get the  
text inserted twice, first as uppercase letters, and then as original  
string, moreover original string should appear in front, since you're  
inserting at the same position.

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