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 ("Application Window", "DemoApplicationWindow.cs", false);
|
||||||
store.AppendValues ("Button Boxes", "DemoButtonBox.cs", false);
|
store.AppendValues ("Button Boxes", "DemoButtonBox.cs", false);
|
||||||
store.AppendValues ("Change Display (0%)", "DemoChangeDisplay.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 ("Color Selector", "DemoColorSelection.cs", false);
|
||||||
store.AppendValues ("Dialog and Message Boxes", "DemoDialog.cs", false);
|
store.AppendValues ("Dialog and Message Boxes", "DemoDialog.cs", false);
|
||||||
store.AppendValues ("Drawing Area", "DemoDrawingArea.cs", false);
|
store.AppendValues ("Drawing Area", "DemoDrawingArea.cs", false);
|
||||||
|
@ -183,7 +184,6 @@ namespace GtkDemo
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: italicize selected row
|
|
||||||
private void OnTreeChanged (object o, EventArgs args)
|
private void OnTreeChanged (object o, EventArgs args)
|
||||||
{
|
{
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
|
@ -214,61 +214,64 @@ namespace GtkDemo
|
||||||
case "2":
|
case "2":
|
||||||
//
|
//
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
|
new DemoClipboard ();
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
new DemoColorSelection ();
|
new DemoColorSelection ();
|
||||||
break;
|
break;
|
||||||
case "4":
|
case "5":
|
||||||
new DemoDialog ();
|
new DemoDialog ();
|
||||||
break;
|
break;
|
||||||
case "5":
|
case "6":
|
||||||
new DemoDrawingArea ();
|
new DemoDrawingArea ();
|
||||||
break;
|
break;
|
||||||
case "6":
|
case "7":
|
||||||
new DemoEntryCompletion ();
|
new DemoEntryCompletion ();
|
||||||
break;
|
break;
|
||||||
case "7":
|
case "8":
|
||||||
new DemoExpander ();
|
new DemoExpander ();
|
||||||
break;
|
break;
|
||||||
case "8":
|
case "9":
|
||||||
new DemoImages ();
|
new DemoImages ();
|
||||||
break;
|
break;
|
||||||
case "9":
|
case "10":
|
||||||
new DemoMenus ();
|
new DemoMenus ();
|
||||||
break;
|
break;
|
||||||
case "10":
|
case "11":
|
||||||
new DemoPanes ();
|
new DemoPanes ();
|
||||||
break;
|
break;
|
||||||
case "11":
|
case "12":
|
||||||
new DemoPixbuf ();
|
new DemoPixbuf ();
|
||||||
break;
|
break;
|
||||||
case "12":
|
case "13":
|
||||||
new DemoSizeGroup ();
|
new DemoSizeGroup ();
|
||||||
break;
|
break;
|
||||||
case "13":
|
|
||||||
new DemoStockBrowser ();
|
|
||||||
break;
|
|
||||||
case "14":
|
case "14":
|
||||||
ToggleRow (args.Path);
|
new DemoStockBrowser ();
|
||||||
break;
|
|
||||||
case "14:0":
|
|
||||||
new DemoHyperText ();
|
|
||||||
break;
|
|
||||||
case "14:1":
|
|
||||||
new DemoTextView ();
|
|
||||||
break;
|
break;
|
||||||
case "15":
|
case "15":
|
||||||
ToggleRow (args.Path);
|
ToggleRow (args.Path);
|
||||||
break;
|
break;
|
||||||
case "15:0":
|
case "15:0":
|
||||||
new DemoEditableCells ();
|
new DemoHyperText ();
|
||||||
break;
|
break;
|
||||||
case "15:1":
|
case "15:1":
|
||||||
|
new DemoTextView ();
|
||||||
|
break;
|
||||||
|
case "16":
|
||||||
|
ToggleRow (args.Path);
|
||||||
|
break;
|
||||||
|
case "16:0":
|
||||||
|
new DemoEditableCells ();
|
||||||
|
break;
|
||||||
|
case "16:1":
|
||||||
new DemoListStore ();
|
new DemoListStore ();
|
||||||
break;
|
break;
|
||||||
case "15:2":
|
case "16:2":
|
||||||
new DemoTreeStore ();
|
new DemoTreeStore ();
|
||||||
break;
|
break;
|
||||||
case "16":
|
case "17":
|
||||||
new DemoUIManager ();
|
new DemoUIManager ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -9,6 +9,7 @@ EXTRA_DIST = $(sources) $(image_names)
|
||||||
sources = \
|
sources = \
|
||||||
DemoApplicationWindow.cs \
|
DemoApplicationWindow.cs \
|
||||||
DemoButtonBox.cs \
|
DemoButtonBox.cs \
|
||||||
|
DemoClipboard.cs \
|
||||||
DemoColorSelection.cs \
|
DemoColorSelection.cs \
|
||||||
DemoDialog.cs \
|
DemoDialog.cs \
|
||||||
DemoDrawingArea.cs \
|
DemoDrawingArea.cs \
|
||||||
|
|
|
@ -3,12 +3,7 @@ General
|
||||||
|
|
||||||
DemoMain
|
DemoMain
|
||||||
- syntax highlighting
|
- syntax highlighting
|
||||||
|
- use reflection to fill the tree/launch demos
|
||||||
DemoIconFactory
|
|
||||||
- I think this is removed > gtk2.4
|
|
||||||
|
|
||||||
DemoImages
|
|
||||||
- improve the Progressive Image loading and error handling
|
|
||||||
|
|
||||||
DemoStockBrowser
|
DemoStockBrowser
|
||||||
- underline _label properly
|
- underline _label properly
|
||||||
|
|
Loading…
Reference in a new issue