diff --git a/sample/GtkDemo/DemoClipboard.cs b/sample/GtkDemo/DemoClipboard.cs new file mode 100644 index 000000000..0a847349b --- /dev/null +++ b/sample/GtkDemo/DemoClipboard.cs @@ -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; + } + } +} + diff --git a/sample/GtkDemo/DemoMain.cs b/sample/GtkDemo/DemoMain.cs index 4600d804f..9eb57a9a0 100644 --- a/sample/GtkDemo/DemoMain.cs +++ b/sample/GtkDemo/DemoMain.cs @@ -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: diff --git a/sample/GtkDemo/Makefile.am b/sample/GtkDemo/Makefile.am index e1d52df32..b9b83cc42 100644 --- a/sample/GtkDemo/Makefile.am +++ b/sample/GtkDemo/Makefile.am @@ -9,6 +9,7 @@ EXTRA_DIST = $(sources) $(image_names) sources = \ DemoApplicationWindow.cs \ DemoButtonBox.cs \ + DemoClipboard.cs \ DemoColorSelection.cs \ DemoDialog.cs \ DemoDrawingArea.cs \ diff --git a/sample/GtkDemo/TODO b/sample/GtkDemo/TODO index ead77d693..7c5902270 100644 --- a/sample/GtkDemo/TODO +++ b/sample/GtkDemo/TODO @@ -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