add clipboard demo from gtk-demo
svn path=/trunk/gtk-sharp/; revision=37667
This commit is contained in:
parent
81c32f1c38
commit
304f9404b4
4 changed files with 102 additions and 31 deletions
72
sample/GtkDemo/DemoClipboard.cs
Normal file
72
sample/GtkDemo/DemoClipboard.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using Gtk;
|
||||
|
||||
namespace GtkDemo
|
||||
{
|
||||
public class DemoClipboard : Gtk.Window
|
||||
{
|
||||
Entry pasteEntry, copyEntry;
|
||||
|
||||
public DemoClipboard () : base ("Demo Clipboard")
|
||||
{
|
||||
this.DeleteEvent += new DeleteEventHandler (OnDelete);
|
||||
|
||||
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);
|
||||
|
||||
this.Add (vbox);
|
||||
this.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 (OnCopyClicked);
|
||||
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 (OnPasteClicked);
|
||||
hbox.PackStart (pasteEntry, true, true, 0);
|
||||
hbox.PackStart (pasteButton, false, false, 0);
|
||||
return hbox;
|
||||
}
|
||||
|
||||
void OnCopyClicked (object sender, EventArgs a)
|
||||
{
|
||||
Clipboard clipboard = copyEntry.GetClipboard (Gdk.Selection.Clipboard);
|
||||
clipboard.SetText (copyEntry.Text);
|
||||
}
|
||||
|
||||
void OnPasteClicked (object sender, EventArgs a)
|
||||
{
|
||||
Clipboard clipboard = pasteEntry.GetClipboard (Gdk.Selection.Clipboard);
|
||||
pasteEntry.Text = clipboard.WaitForText ();
|
||||
}
|
||||
|
||||
void OnDelete (object sender, DeleteEventArgs a)
|
||||
{
|
||||
this.Hide ();
|
||||
this.Destroy ();
|
||||
a.RetVal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -160,6 +160,7 @@ namespace GtkDemo
|
|||
store.AppendValues ("Application Window", "DemoApplicationWindow.cs", false);
|
||||
store.AppendValues ("Button Boxes", "DemoButtonBox.cs", false);
|
||||
store.AppendValues ("Change Display (0%)", "DemoChangeDisplay.cs", false);
|
||||
store.AppendValues ("Clipboard", "DemoClipboard.cs", false);
|
||||
store.AppendValues ("Color Selector", "DemoColorSelection.cs", false);
|
||||
store.AppendValues ("Dialog and Message Boxes", "DemoDialog.cs", false);
|
||||
store.AppendValues ("Drawing Area", "DemoDrawingArea.cs", false);
|
||||
|
@ -183,7 +184,6 @@ namespace GtkDemo
|
|||
return store;
|
||||
}
|
||||
|
||||
//FIXME: italicize selected row
|
||||
private void OnTreeChanged (object o, EventArgs args)
|
||||
{
|
||||
TreeIter iter;
|
||||
|
@ -214,61 +214,64 @@ namespace GtkDemo
|
|||
case "2":
|
||||
//
|
||||
break;
|
||||
case "3":
|
||||
case "3":
|
||||
new DemoClipboard ();
|
||||
break;
|
||||
case "4":
|
||||
new DemoColorSelection ();
|
||||
break;
|
||||
case "4":
|
||||
case "5":
|
||||
new DemoDialog ();
|
||||
break;
|
||||
case "5":
|
||||
case "6":
|
||||
new DemoDrawingArea ();
|
||||
break;
|
||||
case "6":
|
||||
case "7":
|
||||
new DemoEntryCompletion ();
|
||||
break;
|
||||
case "7":
|
||||
case "8":
|
||||
new DemoExpander ();
|
||||
break;
|
||||
case "8":
|
||||
case "9":
|
||||
new DemoImages ();
|
||||
break;
|
||||
case "9":
|
||||
case "10":
|
||||
new DemoMenus ();
|
||||
break;
|
||||
case "10":
|
||||
case "11":
|
||||
new DemoPanes ();
|
||||
break;
|
||||
case "11":
|
||||
case "12":
|
||||
new DemoPixbuf ();
|
||||
break;
|
||||
case "12":
|
||||
case "13":
|
||||
new DemoSizeGroup ();
|
||||
break;
|
||||
case "13":
|
||||
new DemoStockBrowser ();
|
||||
break;
|
||||
case "14":
|
||||
ToggleRow (args.Path);
|
||||
break;
|
||||
case "14:0":
|
||||
new DemoHyperText ();
|
||||
break;
|
||||
case "14:1":
|
||||
new DemoTextView ();
|
||||
new DemoStockBrowser ();
|
||||
break;
|
||||
case "15":
|
||||
ToggleRow (args.Path);
|
||||
break;
|
||||
break;
|
||||
case "15:0":
|
||||
new DemoEditableCells ();
|
||||
new DemoHyperText ();
|
||||
break;
|
||||
case "15:1":
|
||||
new DemoTextView ();
|
||||
break;
|
||||
case "16":
|
||||
ToggleRow (args.Path);
|
||||
break;
|
||||
case "16:0":
|
||||
new DemoEditableCells ();
|
||||
break;
|
||||
case "16:1":
|
||||
new DemoListStore ();
|
||||
break;
|
||||
case "15:2":
|
||||
case "16:2":
|
||||
new DemoTreeStore ();
|
||||
break;
|
||||
case "16":
|
||||
case "17":
|
||||
new DemoUIManager ();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -9,6 +9,7 @@ EXTRA_DIST = $(sources) $(image_names)
|
|||
sources = \
|
||||
DemoApplicationWindow.cs \
|
||||
DemoButtonBox.cs \
|
||||
DemoClipboard.cs \
|
||||
DemoColorSelection.cs \
|
||||
DemoDialog.cs \
|
||||
DemoDrawingArea.cs \
|
||||
|
|
|
@ -3,12 +3,7 @@ General
|
|||
|
||||
DemoMain
|
||||
- syntax highlighting
|
||||
|
||||
DemoIconFactory
|
||||
- I think this is removed > gtk2.4
|
||||
|
||||
DemoImages
|
||||
- improve the Progressive Image loading and error handling
|
||||
- use reflection to fill the tree/launch demos
|
||||
|
||||
DemoStockBrowser
|
||||
- underline _label properly
|
||||
|
|
Loading…
Reference in a new issue