Re: clipboard pasted text highlighting broken?

"Dugas, Alan" <alan dugas analog com> writes:  
> /* Creating entry widget to input search string */
> entry = gtk_entry_new();
> gtk_signal_connect(GTK_OBJECT(entry), "activate",
> 			GTK_SIGNAL_FUNC(find_string), GTK_WIDGET(entry));
> gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(entry), FALSE, FALSE, 0);
> gtk_editable_paste_clipboard(GTK_EDITABLE(GTK_ENTRY(entry)));
> gtk_editable_select_region(GTK_EDITABLE(GTK_ENTRY(entry)), (gint) 0, (gint) -1);
> gtk_widget_show(entry);

There are a couple problems with this code:

 a) you can't paste from the clipboard until the entry is realized,
    because the entry won't receive the selection-related events

 b) paste_clipboard is asynchronous; what happens immediately is that 
    GTK requests the data from the clipboard, then sometime later
    after the event loop runs the data is actually received and 

So maybe what you want to do instead is connect_after() to the
selection_received signal; this signal is emitted when the clipboard
data actually arrives, and its default handler inserts the text, so if
you connect_after() your code will run after the text is inserted.  Be
careful not to rely on receiving the selection after requesting it;
the app that owns it could crash, for example.


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