Selection handling in own widget



Hi,

I have written a text output widget for my program, and naturally I want
the user to be able to select text and paste it in another application,
so I added the following lines to my code:

In the _init function:
  gtk_selection_add_target(GTK_WIDGET (gmo), GDK_SELECTION_PRIMARY,
                           GDK_SELECTION_TYPE_STRING, 1);
Added function references in the _class_init:
  widget_class->selection_clear_event   = gtk_gmo_selection_clear_event;
  widget_class->selection_get           = gtk_gmo_selection_get;

If the user has selected text I use the:
  ok = gtk_selection_owner_set(GTK_WIDGET(gmo),
                               GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
to claim the selection, and if the user then clicks (for example) with the
middle mouse button in an xterm, the gtk_gmo_selection_get function is called,
I fill in the data and everything works.

Well, not very time, and there's the problem. Somtimes, and I can't figure
out when, my _get function doesn't get called...
Another symptom is, that I seem to `loose' the selection, as in that the
gtk_selection_owner_set returns true, but when the user selects the next
letter, gdk_selection_owner_get doesn't match with my GdkWindow...

I tried filling in the other selection related fields, but the only thing I
noticed is that I got an selection_request_event insead of the
selection_get signal, but I don't understand why/what/etc ...
    
I really hope anyone can help, cause I don't get it anymore :(

  Gert

--
begin  LOVE-LETTER-FOR-YOU.TXT.vbs
      I'm a signature virus. Copy me!
end




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