2005-01-02 19:16:41 +00:00
|
|
|
/* Clipboard
|
|
|
|
*
|
|
|
|
* GtkClipboard is used for clipboard handling. This demo shows how to
|
|
|
|
* copy and paste text to and from the clipboard.
|
2005-04-01 21:08:14 +00:00
|
|
|
*
|
|
|
|
* This is actually from gtk+ 2.6's gtk-demo, but doesn't use any 2.6
|
|
|
|
* functionality
|
2005-01-02 19:16:41 +00:00
|
|
|
*/
|
2004-12-12 20:58:08 +00:00
|
|
|
using System;
|
|
|
|
using Gtk;
|
|
|
|
|
2005-04-01 21:08:14 +00:00
|
|
|
namespace GtkDemo
|
2004-12-12 20:58:08 +00:00
|
|
|
{
|
2004-12-12 22:11:44 +00:00
|
|
|
[Demo ("Clipboard", "DemoClipboard.cs")]
|
2004-12-12 20:58:08 +00:00
|
|
|
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);
|
2005-04-01 21:08:14 +00:00
|
|
|
|
|
|
|
Add (vbox);
|
|
|
|
ShowAll ();
|
2004-12-12 20:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HBox CreateCopyBox ()
|
|
|
|
{
|
|
|
|
HBox hbox = new HBox (false, 4);
|
|
|
|
hbox.BorderWidth = 8;
|
|
|
|
copyEntry = new Entry ();
|
|
|
|
Button copyButton = new Button (Stock.Copy);
|
2005-04-01 21:08:14 +00:00
|
|
|
copyButton.Clicked += new EventHandler (CopyClicked);
|
2004-12-12 20:58:08 +00:00
|
|
|
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);
|
2005-04-01 21:08:14 +00:00
|
|
|
pasteButton.Clicked += new EventHandler (PasteClicked);
|
2004-12-12 20:58:08 +00:00
|
|
|
hbox.PackStart (pasteEntry, true, true, 0);
|
|
|
|
hbox.PackStart (pasteButton, false, false, 0);
|
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
2005-04-01 21:08:14 +00:00
|
|
|
void CopyClicked (object obj, EventArgs args)
|
2004-12-12 20:58:08 +00:00
|
|
|
{
|
|
|
|
Clipboard clipboard = copyEntry.GetClipboard (Gdk.Selection.Clipboard);
|
* generator/Parameters.cs (IsHidden): method to check if a
parameter should be hidden in the managed sig (eg, because it's
user_data, or it's the length of the preceding array/string, etc).
(VisibleCount): the number of parameters that will actually be
exposed in the managed signature.
(IsAccessor): test VisibleCount, not Count
(AccessorReturnType, AccessorName): deal with the fact that the
accessor parameter might not be the first one.
* generator/CallbackGen.cs:
* generator/Signature.cs: use Parameters.IsHidden.
* generator/Method.cs (Initialize): set is_set based on
VisibleCount, not Count.
(Validate): call base.Validate() before Initialize() so that
VisibleCount will be correct in Initialize.
* generator/MethodBody.cs (GetCallString, CallArrayLength,
Initialize): update to deal with accessors with multiple args.
* gtk/Clipboard.custom (SetText): implement as an Obsolete variant
of the Text property
* gtk/IconTheme.custom (SearchPath, SetSearchPath): obsolete
SetSearchPath, implement a setter on SearchPath instead.
* gtk/ListStore.custom (SetColumnTypes):
* gtk/TreeStore.custom (SetColumnTypes): implement as an Obsolete
variant of the ColumnTypes property.
* glade/XML.custom (CustomHandler): implement as a property
(SetCustomHandler): Mark this obsolete
* glade/Global.custom (SetCustomHandler): deprecate in favor of
XML.CustomHandler.
* gnomedb/Editor.custom (SetText): implement as an Obsolete
variant of the Text property
svn path=/trunk/gtk-sharp/; revision=43898
2005-05-02 20:10:03 +00:00
|
|
|
clipboard.Text = copyEntry.Text;
|
2004-12-12 20:58:08 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 21:08:14 +00:00
|
|
|
void PasteClicked (object obj, EventArgs args)
|
2004-12-12 20:58:08 +00:00
|
|
|
{
|
|
|
|
Clipboard clipboard = pasteEntry.GetClipboard (Gdk.Selection.Clipboard);
|
2005-04-01 21:08:14 +00:00
|
|
|
clipboard.RequestText (new ClipboardTextReceivedFunc (PasteReceived));
|
2004-12-12 20:58:08 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 21:08:14 +00:00
|
|
|
void PasteReceived (Clipboard clipboard, string text)
|
2004-12-12 20:58:08 +00:00
|
|
|
{
|
2005-04-01 21:08:14 +00:00
|
|
|
pasteEntry.Text = text;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnDeleteEvent (Gdk.Event evt)
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
return true;
|
2004-12-12 20:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|