/usr/share/gtk-sharp3-examples/GtkDemo/DemoClipboard.cs is in gtk-sharp3-examples 2.99.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | /* Clipboard
*
* GtkClipboard is used for clipboard handling. This demo shows how to
* copy and paste text to and from the clipboard.
*
* This is actually from gtk+ 2.6's gtk-demo, but doesn't use any 2.6
* functionality
*/
using System;
using Gtk;
namespace GtkDemo
{
[Demo ("Clipboard", "DemoClipboard.cs")]
public class DemoClipboard : Gtk.Window
{
Entry pasteEntry, copyEntry;
public DemoClipboard () : base ("Demo Clipboard")
{
VBox vbox = new VBox ();
vbox.BorderWidth = 8;
Label copyLabel = new Label ("\"Copy\" will copy the text\nin the entry to the clipboard");
vbox.PackStart (copyLabel, false, true, 0);
vbox.PackStart (CreateCopyBox (), false, true, 0);
Label pasteLabel = new Label ("\"Paste\" will paste the text from the clipboard to the entry");
vbox.PackStart (pasteLabel, false, false, 0);
vbox.PackStart (CreatePasteBox (), false, false, 0);
Add (vbox);
ShowAll ();
}
HBox CreateCopyBox ()
{
HBox hbox = new HBox (false, 4);
hbox.BorderWidth = 8;
copyEntry = new Entry ();
Button copyButton = new Button (Stock.Copy);
copyButton.Clicked += new EventHandler (CopyClicked);
hbox.PackStart (copyEntry, true, true, 0);
hbox.PackStart (copyButton, false, false, 0);
return hbox;
}
HBox CreatePasteBox ()
{
HBox hbox = new HBox (false, 4);
hbox.BorderWidth = 8;
pasteEntry = new Entry ();
Button pasteButton = new Button (Stock.Paste);
pasteButton.Clicked += new EventHandler (PasteClicked);
hbox.PackStart (pasteEntry, true, true, 0);
hbox.PackStart (pasteButton, false, false, 0);
return hbox;
}
void CopyClicked (object obj, EventArgs args)
{
Clipboard clipboard = copyEntry.GetClipboard (Gdk.Selection.Clipboard);
clipboard.Text = copyEntry.Text;
}
void PasteClicked (object obj, EventArgs args)
{
Clipboard clipboard = pasteEntry.GetClipboard (Gdk.Selection.Clipboard);
clipboard.RequestText (new ClipboardTextReceivedFunc (PasteReceived));
}
void PasteReceived (Clipboard clipboard, string text)
{
pasteEntry.Text = text;
}
protected override bool OnDeleteEvent (Gdk.Event evt)
{
Destroy ();
return true;
}
}
}
|