Well I did it, thank you very much! void cb_gtk_handle_selection (GtkTextBuffer *buffer) { GtkTextIter start; GtkTextIter end;
gtk_text_buffer_get_selection_bounds (buffer, &start, &end); } int main () { ... g_signal_connect_swapped (buffer, "notify::has-selection", G_CALLBACK (cb_handle_selection_mouse), buffer); ... } On Fri, Jan 19, 2018 at 9:02 PM, Florian Müllner <fmuell...@gnome.org> wrote: > On Wed, Jan 17, 2018 at 3:19 PM, Lucky B.C <lblack...@gmail.com> wrote: >> I'm trying to get the range of the selected word by >> gtk_text_iter_get_offset (start) and gtk_text_ter_get_offset (end) on >> the “extend-selection” signal, > > Right, that doesn't work. There is no selected word when the signal > handler is run, as it's the handler itself that is responsible for > *setting* the selection in the first place. That is, both 'start' and > 'end' are uninitialized and the handler is expected to set them to the > start and end of the word (or line). If you are fine with the > selection that the default signal handler provides and want to get the > selection bounds, you can connect to the 'notify::has-selection' > signal on the text view's buffer and use > gtk_text_buffer_get_selection_bounds() to get the range. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list