Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GtkEntry text change signal

Tags:

c

gtk

How can I connect a signal callback for any kind of change in a GtkEntry's buffer, including character added, deleted, text pasted or cut? I've looked in the docs for GtkWidget, GtkEntry and GtkEntryBuffer without finding this.

Note: if my question was badly worded, think of the HTML DOM's change event, except that it's fired greedily after every single keypress or event that causes a change, and not only checked on unfocus.

like image 884
Delan Azabani Avatar asked Oct 07 '10 05:10

Delan Azabani


1 Answers

There is the changed signal (of the GtkEditable interface):

The ::changed signal is emitted at the end of a single user-visible operation on the contents of the GtkEditable.

E.g., a paste operation that replaces the contents of the selection will cause only one signal emission (even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple ::notify::text signals to be emitted).

(I found that by checking the implemented interfaces section.)

This indicates that you can also connect to the notify signal of the text property (specifically, notify::text).

There is also the preedit-changed signal:

If an input method is used, the typed text will not immediately be committed to the buffer. So if you are interested in the text, connect to this signal.

like image 65
detly Avatar answered Sep 21 '22 21:09

detly