From 7e906fec7cb92d71f3282a7adf01fdbdc597cb58 Mon Sep 17 00:00:00 2001 From: John Luke Date: Sat, 19 Jun 2004 18:25:02 +0000 Subject: [PATCH] fix the examples in Gtk.* some other miscellaneous stuff svn path=/trunk/gtk-sharp/; revision=29954 --- doc/ChangeLog | 6 ++++ doc/en/Gdk/Drawable.xml | 21 ++++++------ doc/en/Gtk/Bin.xml | 27 +++++---------- doc/en/Gtk/Button.xml | 2 +- doc/en/Gtk/CheckButton.xml | 29 +++++++--------- doc/en/Gtk/Combo.xml | 14 ++------ doc/en/Gtk/Dialog.xml | 2 +- doc/en/Gtk/Drag.xml | 2 +- doc/en/Gtk/Entry.xml | 30 +++++++--------- doc/en/Gtk/FileSelection.xml | 27 ++++++--------- doc/en/Gtk/IconSource.xml | 2 +- doc/en/Gtk/Menu.xml | 24 ++++++------- doc/en/Gtk/Notebook.xml | 21 ++++++------ doc/en/Gtk/Statusbar.xml | 32 ++++++++--------- doc/en/Gtk/ThreadNotify.xml | 8 +++++ doc/en/Gtk/Viewport.xml | 66 ++++++++++++++++++++++++++---------- doc/en/Gtk/Viewport1.cs | 4 +-- doc/en/Rsvg/Tool.xml | 55 +++++++++++++----------------- doc/en/Vte/Terminal.xml | 17 +++++----- 19 files changed, 193 insertions(+), 196 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index f0f51596c..8a7dab814 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2004-06-19 John Luke + + * en/Gtk/*.xml: fix examples so they compile, are children of + so they are editable and spaced right, and some + miscellaneous fixes and updates + 2004-06-17 Mike Kestner * en/Gtk/Window.xml : document remaining TBAs. diff --git a/doc/en/Gdk/Drawable.xml b/doc/en/Gdk/Drawable.xml index 3cc755507..1bf4fb8e0 100644 --- a/doc/en/Gdk/Drawable.xml +++ b/doc/en/Gdk/Drawable.xml @@ -10,7 +10,8 @@ Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. - To be added + Functions for drawing points, lines, arcs, and text. + To be added @@ -129,12 +130,12 @@ - To be added + Render a onto a To be added: an object of type 'Gdk.GC' To be added: an object of type 'int' To be added: an object of type 'int' To be added: an object of type 'Pango.Layout' - To be added + If you are using Gtk, the usual way to obtain a is . @@ -264,7 +265,7 @@ - To be added + Draws a onto a drawable. To be added: an object of type 'Gdk.GC' To be added: an object of type 'Gdk.Image' To be added: an object of type 'int' @@ -273,7 +274,7 @@ To be added: an object of type 'int' To be added: an object of type 'int' To be added: an object of type 'int' - To be added + The depth of the must match the depth of the . @@ -458,11 +459,11 @@ - To be added + Draws a rectangular outline or filled rectangle, using the foreground color and other attributes of the . a a a - To be added + A rectangle drawn filled is 1 pixel smaller in both dimensions than a rectangle outlined. Calling Gdk.DrawRectangle (window, gc, TRUE, 0, 0, 20, 20) results in a filled rectangle 20 pixels wide and 20 pixels high. Calling Gdk.DrawRectangle (window, gc, FALSE, 0, 0, 20, 20) results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which makes it 21 pixels wide and 21 pixels high. @@ -567,14 +568,14 @@ - To be added + Draws a rectangular outline or filled rectangle, using the foreground color and other attributes of the . a a a a a a - To be added + A rectangle drawn filled is 1 pixel smaller in both dimensions than a rectangle outlined. Calling Gdk.DrawRectangle (window, gc, TRUE, 0, 0, 20, 20) results in a filled rectangle 20 pixels wide and 20 pixels high. Calling Gdk.DrawRectangle (window, gc, FALSE, 0, 0, 20, 20) results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which makes it 21 pixels wide and 21 pixels high. @@ -610,7 +611,7 @@ - To be added + This is a constructor used by derivative types of Drawable. This is not typically used by C# code. a To be added diff --git a/doc/en/Gtk/Bin.xml b/doc/en/Gtk/Bin.xml index 26280a8dc..9106195ce 100644 --- a/doc/en/Gtk/Bin.xml +++ b/doc/en/Gtk/Bin.xml @@ -27,8 +27,7 @@ For the widget to be useful, it should participate in size negotiation and size allocation using the events and . - Since Gtk.Bin is an abstract class in C, it is necessary to - register a Type. Sample follows. + Sample follows. @@ -40,19 +39,9 @@ using Gtk; // class MyPadder : Bin { int pad = 50; - static GLib.Type type; Widget child; - static MyPadder () - { - // - // Register the type on the static constructor, so it is - // available on the instance constructors - // - type = RegisterGType (typeof (MyPadder)); - } - - public MyPadder () : base (type) + public MyPadder () { // To track our child widget. Added += new AddedHandler (MyAdded); @@ -68,8 +57,8 @@ class MyPadder : Bin { void OnSizeRequested (object o, SizeRequestedArgs args) { if (child != null){ - int width = args.Requisition.width; - int height = args.Requisition.height; + int width = args.Requisition.Width; + int height = args.Requisition.Height; child.GetSizeRequest (out width, out height); if (width == -1 || height == -1) @@ -88,10 +77,10 @@ class MyPadder : Bin { Gdk.Rectangle mine = args.Allocation; Gdk.Rectangle his = mine; - his.x += pad; - his.y += pad; - his.width -= pad * 2; - his.height -= pad * 2; + his.X += pad; + his.Y += pad; + his.Width -= pad * 2; + his.Height -= pad * 2; child.SizeAllocate (his); } } diff --git a/doc/en/Gtk/Button.xml b/doc/en/Gtk/Button.xml index fc8224798..28d142163 100644 --- a/doc/en/Gtk/Button.xml +++ b/doc/en/Gtk/Button.xml @@ -28,7 +28,7 @@ public class ButtonApp { { Application.Init (); Window win = new Window ("Button Tester"); - win.DefaultSize = new Size (200, 150); + win.SetDefaultSize (200, 150); win.DeleteEvent += new DeleteEventHandler (Window_Delete); Button btn = new Button ("Click Me"); btn.Clicked += new EventHandler (btn_click); diff --git a/doc/en/Gtk/CheckButton.xml b/doc/en/Gtk/CheckButton.xml index 2b454e42a..cf41ea585 100644 --- a/doc/en/Gtk/CheckButton.xml +++ b/doc/en/Gtk/CheckButton.xml @@ -14,40 +14,34 @@ A places a discrete next to a widget, usually a . See for more information about toggle/check buttons. - - - - + + + using System; using Gtk; class CheckButtonSample { CheckButton cb; - static void Main () { - new CheckButtonSample (); + new CheckButtonSample (); } - + CheckButtonSample () { Application.Init (); - Window win = new Window ("CheckButtonSample"); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); - VBox vbox = new VBox (true, 1); win.Add (vbox); - cb = new CheckButton ("Checked"); cb.Toggled += new EventHandler (OnCheckToggled); - vbox.Add (cb); - + vbox.Add (cb); win.ShowAll (); Application.Run (); } - + void OnCheckToggled (object obj, EventArgs args) { if (cb.Label == "Checked") @@ -59,14 +53,15 @@ class CheckButtonSample cb.Label = "Checked"; } } - + void OnWinDelete (object obj, DeleteEventArgs args) { Application.Quit (); } -} - - +} + + + Gtk.ToggleButton diff --git a/doc/en/Gtk/Combo.xml b/doc/en/Gtk/Combo.xml index cf189d696..d5c502951 100644 --- a/doc/en/Gtk/Combo.xml +++ b/doc/en/Gtk/Combo.xml @@ -35,9 +35,7 @@ using System; -using System.Runtime.InteropServices; using Gtk; -using GLib; class ComboSample { @@ -55,15 +53,10 @@ class ComboSample Window win = new Window ("ComboSample"); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); - GLib.List l = new GLib.List (IntPtr.Zero, typeof (string)); - - for (int i =0; i < 5; i++) - { - l.Append ("String " + i); - } + string[] list = new string[] {"one", "two", "three"}; combo = new Combo (); - combo.PopdownStrings = l; + combo.PopdownStrings = list; combo.DisableActivate (); combo.Entry.Activated += new EventHandler (OnEntryActivated); @@ -84,9 +77,6 @@ class ComboSample } } - - See for more about GLib.List. - diff --git a/doc/en/Gtk/Dialog.xml b/doc/en/Gtk/Dialog.xml index 3dc161136..40828d39e 100644 --- a/doc/en/Gtk/Dialog.xml +++ b/doc/en/Gtk/Dialog.xml @@ -55,7 +55,7 @@ namespace GtkDialogSample dialog = new Dialog ("Sample", win, Gtk.DialogFlags.DestroyWithParent); dialog.Modal = true; - dialog.AddButton ("Close", 5); + dialog.AddButton ("Close", ResponseType.Close); dialog.Response += new ResponseHandler (on_dialog_response); dialog.Run (); dialog.Destroy (); diff --git a/doc/en/Gtk/Drag.xml b/doc/en/Gtk/Drag.xml index 1c4f3f6fe..e4163f8a1 100644 --- a/doc/en/Gtk/Drag.xml +++ b/doc/en/Gtk/Drag.xml @@ -13,7 +13,7 @@ Methods for controlling drag and drop handling. - GTK# has a rich set of methods for doing inter-process communication via the drag-and-drop metaphor. GTK# can do drag-and-drop (DND) via multiple protocols. The currently supported protocols are the Xdnd and Motif protocols. As well as the methods listed here, applications may need to use some facilities provided for . Also, the Drag and Drop API makes use of events in the class. + Gtk# has a rich set of methods for doing inter-process communication via the drag-and-drop metaphor. Gtk# can do drag-and-drop (DND) via multiple protocols. The currently supported protocols are the Xdnd and Motif protocols. As well as the methods listed here, applications may need to use some facilities provided for . Also, the Drag and Drop API makes use of events in the class. diff --git a/doc/en/Gtk/Entry.xml b/doc/en/Gtk/Entry.xml index ddd721492..64a7b5ca1 100644 --- a/doc/en/Gtk/Entry.xml +++ b/doc/en/Gtk/Entry.xml @@ -16,68 +16,62 @@ See also the widget for displaying and editing large amounts of text. - - - + + using System; using Gtk; class EntrySample { Entry entry; - + static void Main () { - new EntrySample (); + new EntrySample (); } - + EntrySample () { Application.Init (); - Window win = new Window ("EntrySample"); win.SetDefaultSize (200, 150); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); - VBox vbox = new VBox (false, 1); win.Add (vbox); - entry = new Entry ("hello world"); entry.Editable = true; entry.Visibility = true; vbox.Add (entry); - CheckButton editable = new CheckButton ("Editable"); editable.Toggled += new EventHandler (OnEditableToggled); editable.Active = true; vbox.Add (editable); - CheckButton visibility = new CheckButton ("Visibility"); visibility.Toggled += new EventHandler (OnVisibilityToggled); visibility.Active = true; vbox.Add (visibility); - win.ShowAll (); Application.Run (); } - + void OnEditableToggled (object obj, EventArgs args) { entry.Editable = !entry.Editable; } - + void OnVisibilityToggled (object obj, EventArgs args) { entry.Visibility = !entry.Visibility; } - + void OnWinDelete (object obj, DeleteEventArgs args) { Application.Quit (); } -} - - +} + + + Gtk.Widget diff --git a/doc/en/Gtk/FileSelection.xml b/doc/en/Gtk/FileSelection.xml index 0b6026116..d443ad43f 100644 --- a/doc/en/Gtk/FileSelection.xml +++ b/doc/en/Gtk/FileSelection.xml @@ -22,43 +22,37 @@ The functionality of the can be extended by using the available accessors to the buttons and drop downs. - - - + + using System; using Gtk; class FileSelectionSample { Label lbl; - + static void Main () { - new FileSelectionSample (); + new FileSelectionSample (); } - + FileSelectionSample () { Application.Init (); - Window win = new Window ("FileSelectionSample"); win.SetDefaultSize (250,200); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); - VBox vbox = new VBox (true, 1); win.Add (vbox); - Button btn = new Button ("Select a file."); btn.Clicked += new EventHandler (OnButtonClicked); vbox.Add (btn); - lbl = new Label ("Selected: "); vbox.Add (lbl); - win.ShowAll (); Application.Run (); } - + void OnButtonClicked (object o, EventArgs args) { FileSelection fs = new FileSelection ("Choose a file"); @@ -66,14 +60,15 @@ class FileSelectionSample lbl.Text = "Selected: " + fs.SelectionEntry.Text; fs.Hide (); } - + void OnWinDelete (object o, DeleteEventArgs args) { Application.Quit (); } -} - - +} + + + Gtk.Dialog diff --git a/doc/en/Gtk/IconSource.xml b/doc/en/Gtk/IconSource.xml index 4e62bdc24..64712e3d2 100644 --- a/doc/en/Gtk/IconSource.xml +++ b/doc/en/Gtk/IconSource.xml @@ -21,7 +21,7 @@ - A GtkIconSource contains a (or image + A contains a (or image filename) that serves as the base image for one or more of the icons in a , along with a specification for which icons in the icon set will be based on diff --git a/doc/en/Gtk/Menu.xml b/doc/en/Gtk/Menu.xml index 4b5b52fce..a341ae05c 100644 --- a/doc/en/Gtk/Menu.xml +++ b/doc/en/Gtk/Menu.xml @@ -18,39 +18,38 @@ It is commonly dropped down by activating a in a or in another , it can also be popped up by activating a . Other composite widgets such as the can pop up a as well. - - - + + using System; using Gtk; -public class MenuApp { - +public class MenuApp +{ public static void Main (string[] args) { Application.Init(); + Window win = new Window ("Menu Sample App"); win.DeleteEvent += new DeleteEventHandler (delete_cb); win.SetDefaultSize (200, 150); VBox box = new VBox (false, 2); - MenuBar mb = new MenuBar (); Menu file_menu = new Menu (); MenuItem exit_item = new MenuItem("Exit"); exit_item.Activated += new EventHandler (exit_cb); file_menu.Append (exit_item); + MenuItem file_item = new MenuItem("File"); file_item.Submenu = file_menu; mb.Append (file_item); - box.PackStart(mb, false, false, 0); + box.PackStart(mb, false, false, 0); Button btn = new Button ("Yep, that's a menu"); box.PackStart(btn, true, true, 0); - + win.Add (box); win.ShowAll (); - Application.Run (); } @@ -63,9 +62,10 @@ public class MenuApp { { Application.Quit (); } -} - - +} + + + Gtk.MenuShell diff --git a/doc/en/Gtk/Notebook.xml b/doc/en/Gtk/Notebook.xml index 292482789..8619c0747 100644 --- a/doc/en/Gtk/Notebook.xml +++ b/doc/en/Gtk/Notebook.xml @@ -32,9 +32,8 @@ switch between different groups of information to reduce any flicker caused by widget relayout by the application. - - - + + using System; using Gtk; @@ -42,13 +41,12 @@ class NotebookSample { static void Main () { - new NotebookSample (); + new NotebookSample (); } - + NotebookSample () { Application.Init (); - Window win = new Window ("NotebookSample"); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); win.SetDefaultSize (400, 400); @@ -59,19 +57,20 @@ class NotebookSample string label = String.Format ("Page {0}", i+1); nb.AppendPage (new Button (label), new Label (label)); } - + win.Add (nb); win.ShowAll (); Application.Run (); } - + void OnWinDelete (object obj, DeleteEventArgs args) { Application.Quit (); } -} - - +} + + + Gtk.Container diff --git a/doc/en/Gtk/Statusbar.xml b/doc/en/Gtk/Statusbar.xml index f45b679d7..3cb07210a 100644 --- a/doc/en/Gtk/Statusbar.xml +++ b/doc/en/Gtk/Statusbar.xml @@ -18,9 +18,8 @@ Status bars in Gtk maintain a stack of messages. The message at the top of the each bar's stack is the one that will currently be displayed. Any messages added to a statusbar's stack must specify a that is used to uniquely identify the source of a message. This can be generated with , given a message. Note that messages are stored in a stack, and when choosing which message to display, the stack structure is adhered to, regardless of the context identifier of a message. Messages are added to the bar's stack with , and the message at the top of the stack can be removed using . A message can be removed from anywhere in the stack if it's was recorded at the time it was added. This is done using . - - - + + using System; using Gtk; @@ -29,38 +28,36 @@ class StatusbarSample Statusbar sb; const int id = 1; int count; - + static void Main () { - new StatusbarSample (); + new StatusbarSample (); } - + StatusbarSample () { Application.Init (); - count = 0; - Window win = new Window ("StatusbarSample"); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); win.SetDefaultSize (150, 100); - + VBox vbox = new VBox (false, 1); win.Add (vbox); - + Button btn = new Button ("Add to counter"); btn.Clicked += new EventHandler (OnButtonClicked); vbox.Add (btn); - + sb = new Statusbar (); sb.Push (id, "Welcome!"); sb.HasResizeGrip = false; vbox.Add (sb); - + win.ShowAll (); Application.Run (); } - + void OnButtonClicked (object obj, EventArgs args) { count ++; @@ -68,14 +65,15 @@ class StatusbarSample sb.Pop (id); sb.Push (id, message); } - + void OnWinDelete (object obj, DeleteEventArgs args) { Application.Quit (); } -} - - +} + + + Gtk.HBox diff --git a/doc/en/Gtk/ThreadNotify.xml b/doc/en/Gtk/ThreadNotify.xml index df20e1a39..563f94a8a 100644 --- a/doc/en/Gtk/ThreadNotify.xml +++ b/doc/en/Gtk/ThreadNotify.xml @@ -19,6 +19,9 @@ using Gtk; class Demo { + + static ThreadNotify notify; + static void Main () { Application.Init (); @@ -36,6 +39,11 @@ class Demo { LargeComputation (); notify.WakeupMain (); } + + static void LargeComputation () + { + // lots of processing here + } } diff --git a/doc/en/Gtk/Viewport.xml b/doc/en/Gtk/Viewport.xml index a85f8d63a..d6bcd8eba 100644 --- a/doc/en/Gtk/Viewport.xml +++ b/doc/en/Gtk/Viewport.xml @@ -17,26 +17,56 @@ The appearance of the Viewport can be adjusted using the property. The following example creates a in a Viewport. When placed in a small , the widgets can be scrolled. + - -public ScrolledWindow CreateViewport() -{ - ScrolledWindow scroller = new ScrolledWindow(); - Viewport viewer = new Viewport(); - - // Create a table with text entries in it - Table widgets = new Table(1, 2, false); - widgets.Attach(new Entry("This is example Entry 1"), 0, 1, 0, 1); - widgets.Attach(new Entry("This is example Entry 2"), 1, 2, 0, 1); - - // Place the widgets in a Viewport, and the Viewport in a ScrolledWindow - viewer.Add(widgets); - scroller.Add(viewer); - return scroller; + +namespace GtkSamples { + + using Gtk; + using System; + + public class ViewportApp { + + public static ScrolledWindow CreateViewport() + { + ScrolledWindow scroller = new ScrolledWindow(); + Viewport viewer = new Viewport(); + + Table widgets = new Table(1, 2, false); + + widgets.Attach(new Entry("This is example Entry 1"), 0, 1, 0, 1); + widgets.Attach(new Entry("This is example Entry 2"), 1, 2, 0, 1); + + // Place the widgets in a Viewport, and the Viewport in a ScrolledWindow + viewer.Add(widgets); + scroller.Add(viewer); + return scroller; + } + + public static int Main (string[] args) + { + Application.Init (); + Window win = new Window ("Viewport Tester"); + win.SetDefaultSize (180, 50); + win.DeleteEvent += new DeleteEventHandler (Window_Delete); + ScrolledWindow scroller = CreateViewport(); + win.Add (scroller); + win.ShowAll (); + Application.Run (); + return 0; + } + + static void Window_Delete (object obj, DeleteEventArgs args) + { + Application.Quit (); + args.RetVal = true; + } + + } } - - - Complete example: + + + diff --git a/doc/en/Gtk/Viewport1.cs b/doc/en/Gtk/Viewport1.cs index a7aaa14bd..d9a760efa 100755 --- a/doc/en/Gtk/Viewport1.cs +++ b/doc/en/Gtk/Viewport1.cs @@ -7,9 +7,7 @@ namespace GtkSamples { using Gtk; - using GtkSharp; using System; - using System.Drawing; public class ViewportApp { @@ -33,7 +31,7 @@ namespace GtkSamples { { Application.Init (); Window win = new Window ("Viewport Tester"); - win.DefaultSize = new Size (180, 50); + win.SetDefaultSize (180, 50); win.DeleteEvent += new DeleteEventHandler (Window_Delete); ScrolledWindow scroller = CreateViewport(); win.Add (scroller); diff --git a/doc/en/Rsvg/Tool.xml b/doc/en/Rsvg/Tool.xml index 37cff6067..0201e6f9b 100644 --- a/doc/en/Rsvg/Tool.xml +++ b/doc/en/Rsvg/Tool.xml @@ -11,51 +11,44 @@ Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. To be added - To be added - - + + + +using System; +using Gtk; + class SvgHelloWorld { - static void Main(string[] args) + static void Main (string[] args) { - Gnome.Program program = - new Gnome.Program("Hello World", "1.0", Gnome.Modules.UI, args); - - MyMainWindow app = new MyMainWindow(program); - app.Show(); - - program.Run(); + Application.Init (); + MyMainWindow app = new MyMainWindow (); + app.ShowAll (); + Application.Run (); } } -class MyMainWindow - : Gnome.App +class MyMainWindow : Gtk.Window { - Gnome.Program program; - - public MyMainWindow(Gnome.Program gnome_program) - : base("SVG Hello World", "SVG Hello World") + public MyMainWindow () : base ("SVG Hello World") { - this.program = gnome_program; - - this.DeleteEvent += new GtkSharp.DeleteEventHandler(delete_event); - + this.DeleteEvent += new DeleteEventHandler (delete_event); string svg_file_name = "sample.svg"; - Gdk.Pixbuf pixbuf = Rsvg.Tool.PixbufFromFile(svg_file_name); - - Gtk.Image image = new Gtk.Image(); + Gdk.Pixbuf pixbuf = Rsvg.Tool.PixbufFromFile (svg_file_name); + Image image = new Image (); image.Pixbuf = pixbuf; - - this.Contents = image; + this.Add (image); } - private void delete_event(object obj, GtkSharp.DeleteEventArgs args) + private void delete_event (object obj, DeleteEventArgs args) { - this.program.Quit(); + Application.Quit (); } -} - - +} + + + + System.Object diff --git a/doc/en/Vte/Terminal.xml b/doc/en/Vte/Terminal.xml index 77c731f22..68bf5ee91 100644 --- a/doc/en/Vte/Terminal.xml +++ b/doc/en/Vte/Terminal.xml @@ -10,8 +10,9 @@ Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. - To be added - To be added + A terminal widget implementation. + + A is a terminal emulator implemented as a Gtk.Widget @@ -735,10 +736,10 @@ - To be added + Internal Constructor. a a - To be added + This should not be called by normal applications. @@ -749,10 +750,10 @@ - To be added + Internal Constructor. a a - To be added + This should not be called by normal user code. @@ -761,9 +762,9 @@ - To be added + Default Constructor a - To be added +