[gtkada] Help Needed for Win32 GtkAda "Paste" to Clipboard
Warren W. Gay VE3WWG
ve3wwg at home.com
Mon Mar 5 15:29:44 CET 2001
Ok.. I surrender. I've beat my brain against the wall to much
on this one already....
What I want to do, is paste a password(string) from my GtkAda
key_chain app, to the Windows clipboard. I've seen some
pretty complicated Drag and Drop code etc., and even some cut
and paste code in C, for Gtk+. However, I am still not getting
very far in my attempt to paste a simple string to the clipboard.
If someone has better GtkAda instructions/example code somewhere,
that would help. The GtkAda documentation doesn't tell you enough,
and what I could find, the examples don't cut it either. Even worse,
I suspect that the "procedure" has changed, but the documentation
has not kept pace.
DESCRIPTION:
In my Main_Win_Pkg, I have:
The_Clipboard: Gdk_Selection;
delcared in the spec. It is initialized, with:
The_Clipboard := Gdk.Property.Atom.Itern("CLIPBOARD");
Later, after the windows 'n widgets are created, I have:
Add_Target(Main_Win.Ed_Password,The_Clipboard,Target_String,1);
Return_Callback.Connect
(Main_Win.Ed_Password, "selection_clear_event",
On_Cb_Copy_Password_Selection_Clear_Event'Access);
Entry_Callback.Connect
(Main_Win.Ed_Password, "selection_get",
On_Cb_Copy_Password_Selection_Get'Access);
The widget Main_Win.Ed_Password is a Gtk_Entry widget.
With these calls in place, I now finally get the "selection_get" event
and callback (the C example I had used a checkbox, but they don't get
these events anymore it seems).
The On_Cb_Copy_Password_Selection_Get callback, looks as follows:
procedure On_Cb_Copy_Password_Selection_Get
(Object : access Gtk_Entry_Record'Class;
Params : Gtk.Arguments.Gtk_Args)
is
Data : Selection_Data := Selection_Data( To_C_Proxy(Params,1) );
Arg2 : Guint := To_Guint (Params, 2);
Arg3 : Guint := To_Guint (Params, 3);
begin
Selection_Data_Set(Data,Selection_Type_String,8,"<TEST-PASTE>");
end On_Cb_Copy_Password_Selection_Get;
The ownership of the clipboard is established in the toggle-button's
callback as follows:
Flg := Owner_Set(Gtk_Widget(Main_Win.Ed_Password),The_Clipboard);
With this code, I now get a paste of the string "<TEST-PASTE>" to
appear in notepad. HOWEVER, when I select a piece
of text in notepad (or anywhere else), I do _NOT_ get the
"selection_clear_event" callback event.
Even worse, when I exit my
app, and restart it, then attempt to paste into the same notepad (that
was still running), it then pauses for a time, and then brings up a
printer dialog after I have pressed Shift-INS in notepad. Clearly, things
are not working correctly yet.
These experiences are occurring under Windows 2000, using GNAT 3.13p
using GtkAda 1.2.10.
I get the feeling that the whole cut and paste "procedure" underwent
some change in GtkAda and/or Gtk+, but can find mightly little
documentation on this. I only need to "copy" a string to the clipboard.
Nothing else.
TIA, Warren.
More information about the gtkada
mailing list