From db410e94977cdb4b410bb422d5c3b464d212d488 Mon Sep 17 00:00:00 2001 From: John Luke Date: Sat, 7 Aug 2004 17:06:29 +0000 Subject: [PATCH] implement some of the DemoApplicationWindow fix some bugs in DemoEditableCells use more consistent tabs and spaces add a TODO of what is left use the using () pattern to dispose Dialogs automatically use args.RetVal when handling the DeleteEvent svn path=/trunk/gtk-sharp/; revision=32017 --- sample/GtkDemo/.cvsignore | 2 + sample/GtkDemo/DemoApplicationWindow.cs | 57 +++-- sample/GtkDemo/DemoButtonBox.cs | 22 +- sample/GtkDemo/DemoColorSelection.cs | 57 ++--- sample/GtkDemo/DemoDialog.cs | 96 ++++---- sample/GtkDemo/DemoDrawingArea.cs | 33 ++- sample/GtkDemo/DemoEditableCells.cs | 85 +++----- sample/GtkDemo/DemoImages.cs | 29 ++- sample/GtkDemo/DemoItemFactory.cs | 16 +- sample/GtkDemo/DemoListStore.cs | 85 ++++---- sample/GtkDemo/DemoMain.cs | 168 +++++++------- sample/GtkDemo/DemoMenus.cs | 25 +-- sample/GtkDemo/DemoPanes.cs | 48 ++-- sample/GtkDemo/DemoPixbuf.cs | 279 ++++++++++++------------ sample/GtkDemo/DemoSizeGroup.cs | 29 ++- sample/GtkDemo/DemoStockBrowser.cs | 30 +-- sample/GtkDemo/DemoTextView.cs | 167 +++++++------- sample/GtkDemo/DemoTreeStore.cs | 88 ++++---- sample/GtkDemo/TODO | 18 ++ 19 files changed, 636 insertions(+), 698 deletions(-) create mode 100644 sample/GtkDemo/TODO diff --git a/sample/GtkDemo/.cvsignore b/sample/GtkDemo/.cvsignore index 282522db0..dc3628126 100644 --- a/sample/GtkDemo/.cvsignore +++ b/sample/GtkDemo/.cvsignore @@ -1,2 +1,4 @@ Makefile Makefile.in +GtkDemo.exe +GtkDemo.exe.mdb diff --git a/sample/GtkDemo/DemoApplicationWindow.cs b/sample/GtkDemo/DemoApplicationWindow.cs index eb6e47495..134425ecf 100644 --- a/sample/GtkDemo/DemoApplicationWindow.cs +++ b/sample/GtkDemo/DemoApplicationWindow.cs @@ -19,24 +19,29 @@ using Gtk; namespace GtkDemo { - public class DemoApplicationWindow + public class DemoApplicationWindow : Window { - private Gtk.Window window; + // for the statusbar + const int ctx = 1; + const string fmt = "Cursor at row {0} column {1} - {2} chars in document"; + int row, column, count = 0; + + Statusbar statusbar; + // static ItemFactoryEntry items[] = { new ItemFactoryEntry ("/_File", null, 0, 0, "" )}; - public DemoApplicationWindow () + public DemoApplicationWindow () : base ("Demo Application Window") { - window = new Gtk.Window ("Demo Application Window"); - window.SetDefaultSize (400, 300); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.SetDefaultSize (400, 300); + this.DeleteEvent += new DeleteEventHandler (WindowDelete); VBox vbox = new VBox (false, 0); - window.Add (vbox); + this.Add (vbox); // Create the menubar AccelGroup accelGroup = new AccelGroup (); - window.AddAccelGroup (accelGroup); + this.AddAccelGroup (accelGroup); MenuBar menubar = CreateMenu (); vbox.PackStart (menubar, false, false, 0); @@ -45,10 +50,12 @@ namespace GtkDemo vbox.PackStart (toolbar, false, false, 0); TextView textview = new TextView (); + textview.Buffer.MarkSet += new MarkSetHandler (OnMarkSet); vbox.PackStart (textview, true, true, 0); - Statusbar statusbar = new Statusbar (); - statusbar.Push (1, "Cursor at row 0 column 0 - 0 chars in document"); + statusbar = new Statusbar (); + UpdateStatus (); + vbox.PackStart (statusbar, false, false, 0); //ItemFactory itemFactory = new ItemFactory (typeof (MenuBar),"
", accelGroup); @@ -63,7 +70,7 @@ namespace GtkDemo // create menu items //STUCK : Didn't find any examples of ItemFactory - window.ShowAll (); + this.ShowAll (); } private MenuBar CreateMenu () @@ -95,16 +102,32 @@ namespace GtkDemo private void OnToolbarClicked (object o, EventArgs args) { - MessageDialog md = new MessageDialog (window, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "You selected a toolbar button."); - md.Run (); - md.Hide (); - md.Dispose (); + using (MessageDialog md = new MessageDialog (this, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "You selected a toolbar button.")) { + md.Run (); + md.Hide (); + } } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; + } + + void OnMarkSet (object o, MarkSetArgs args) + { + TextIter iter = args.Location; + row = iter.Line + 1; + column = iter.VisibleLineOffset; + count = args.Mark.Buffer.CharCount; + UpdateStatus (); + } + + void UpdateStatus () + { + statusbar.Pop (ctx); + statusbar.Push (ctx, String.Format (fmt, row, column, count)); } } } diff --git a/sample/GtkDemo/DemoButtonBox.cs b/sample/GtkDemo/DemoButtonBox.cs index 879abdd52..b39606366 100644 --- a/sample/GtkDemo/DemoButtonBox.cs +++ b/sample/GtkDemo/DemoButtonBox.cs @@ -12,25 +12,20 @@ */ using System; - using Gtk; namespace GtkDemo { - public class DemoButtonBox + public class DemoButtonBox : Gtk.Window { - private Gtk.Window window; - - public DemoButtonBox () + public DemoButtonBox () : base ("Button Boxes") { - // Create a Window - window = new Gtk.Window ("Button Boxes"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); - window.BorderWidth = 10; + this.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.BorderWidth = 10; // Add Vertical Box VBox mainVbox = new VBox (false,0); - window.Add (mainVbox); + this.Add (mainVbox); // Add Horizontal Frame Frame horizontalFrame = new Frame ("Horizontal Button Boxes"); @@ -58,7 +53,7 @@ namespace GtkDemo hbox.PackStart(CreateButtonBox (false, "Start (spacing 20)", 20, 85, 20, ButtonBoxStyle.Start)); hbox.PackStart(CreateButtonBox (false, "End (spacing 20)", 20, 85, 20, ButtonBoxStyle.End)); - window.ShowAll (); + this.ShowAll (); } // Create a Button Box with the specified parameters @@ -95,8 +90,9 @@ namespace GtkDemo private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } } } diff --git a/sample/GtkDemo/DemoColorSelection.cs b/sample/GtkDemo/DemoColorSelection.cs index 20386c4fa..8a4ccd2b8 100644 --- a/sample/GtkDemo/DemoColorSelection.cs +++ b/sample/GtkDemo/DemoColorSelection.cs @@ -13,28 +13,23 @@ */ using System; - using Gdk; using Gtk; - namespace GtkDemo { - public class DemoColorSelection + public class DemoColorSelection : Gtk.Window { - private Gtk.Window window ; private Gdk.Color color; - private ColorSelectionDialog colorSelectionDialog; private Gtk.DrawingArea drawingArea; - public DemoColorSelection () + public DemoColorSelection () : base ("Color Selection") { - window = new Gtk.Window ("Color Selection"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); - window.BorderWidth = 8; + this.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.BorderWidth = 8; VBox vbox = new VBox (false,8); vbox.BorderWidth = 8; - window.Add (vbox); + this.Add (vbox); // Create the color swatch area Frame frame = new Frame (); @@ -56,13 +51,14 @@ namespace GtkDemo alignment.Add (button); vbox.PackStart (alignment); - window.ShowAll (); + this.ShowAll (); } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } // Expose callback for the drawing area @@ -72,7 +68,7 @@ namespace GtkDemo Gdk.Window window = eventExpose.Window; Rectangle area = eventExpose.Area; - window.DrawRectangle (drawingArea.Style.BackgroundGC(StateType.Normal), + window.DrawRectangle (drawingArea.Style.BackgroundGC (StateType.Normal), true, area.X, area.Y, area.Width, area.Height); @@ -81,28 +77,21 @@ namespace GtkDemo private void ChangeColorCallback (object o, EventArgs args) { - colorSelectionDialog = new ColorSelectionDialog ("Changing color"); - colorSelectionDialog.TransientFor = window; - colorSelectionDialog.ColorSelection.PreviousColor = color; - colorSelectionDialog.ColorSelection.CurrentColor = color; - colorSelectionDialog.ColorSelection.HasPalette = true; + using (ColorSelectionDialog colorSelectionDialog = new ColorSelectionDialog ("Changing color")) { + colorSelectionDialog.TransientFor = this; + colorSelectionDialog.ColorSelection.PreviousColor = color; + colorSelectionDialog.ColorSelection.CurrentColor = color; + colorSelectionDialog.ColorSelection.HasPalette = true; - colorSelectionDialog.CancelButton.Clicked += new EventHandler (Color_Selection_Cancel); - colorSelectionDialog.OkButton.Clicked += new EventHandler (Color_Selection_OK); + if (colorSelectionDialog.Run () == (int) ResponseType.Ok) + { + Gdk.Color selected = colorSelectionDialog.ColorSelection.CurrentColor; + drawingArea.ModifyBg (StateType.Normal, selected); + } - colorSelectionDialog.ShowAll(); - } - - private void Color_Selection_OK (object o, EventArgs args) - { - Gdk.Color selected = colorSelectionDialog.ColorSelection.CurrentColor; - drawingArea.ModifyBg (StateType.Normal, selected); - colorSelectionDialog.Destroy (); - } - - private void Color_Selection_Cancel (object o, EventArgs args) - { - colorSelectionDialog.Destroy (); + colorSelectionDialog.Hide (); + } } } } + diff --git a/sample/GtkDemo/DemoDialog.cs b/sample/GtkDemo/DemoDialog.cs index c609ea8de..b59aae712 100644 --- a/sample/GtkDemo/DemoDialog.cs +++ b/sample/GtkDemo/DemoDialog.cs @@ -16,26 +16,24 @@ // - Check how to handle response type. Can we make the button to have // the binding to the cancel signal automagicly like in // gtk_dialog_new_with_buttons or should we just use the if ? -using System; +using System; using Gtk; namespace GtkDemo { - public class DemoDialog + public class DemoDialog : Gtk.Window { - private Gtk.Window window; private Entry entry1; private Entry entry2; - public DemoDialog () + public DemoDialog () : base ("Dialogs") { - window = new Gtk.Window ("Dialogs"); - window.DeleteEvent += new DeleteEventHandler(WindowDelete); - window.BorderWidth = 8; + this.DeleteEvent += new DeleteEventHandler(WindowDelete); + this.BorderWidth = 8; Frame frame = new Frame ("Dialogs"); - window.Add (frame); + this.Add (frame); VBox vbox = new VBox (false, 8); vbox.BorderWidth = 8; @@ -76,73 +74,79 @@ namespace GtkDemo table.Attach (entry2, 1, 2, 1, 2); label.MnemonicWidget = entry2; - window.ShowAll (); + this.ShowAll (); } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } private int i = 1; private void MessageDialogClicked (object o, EventArgs args) { - string message = String.Format("This message box has been popped up the following\n number of times:\n\n {0:D} ", i); - Dialog dialog = new MessageDialog(window, + string message = String.Format ("This message box has been popped up the following\n number of times:\n\n {0:D} ", i); + + using (Dialog dialog = new MessageDialog (this, DialogFlags.Modal | DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, - message); - dialog.Run (); - dialog.Destroy (); + message)) { + dialog.Run (); + dialog.Hide (); + } + i++; } private void InteractiveDialogClicked (object o, EventArgs args) { - MessageDialog dialog = new MessageDialog (window, + using (MessageDialog dialog = new MessageDialog (this, DialogFlags.Modal | DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.Ok, - null); + null)) { - dialog.AddButton ("_Non-stock Button", (int) ResponseType.Cancel); + dialog.AddButton ("_Non-stock Button", (int) ResponseType.Cancel); - HBox hbox = new HBox (false, 8); - hbox.BorderWidth = 8; - dialog.VBox.PackStart (hbox, false, false, 0); + HBox hbox = new HBox (false, 8); + hbox.BorderWidth = 8; + dialog.VBox.PackStart (hbox, false, false, 0); - Table table = new Table (2, 2, false); - table.RowSpacing = 4; - table.ColumnSpacing = 4; - hbox.PackStart (table, false, false, 0); + Table table = new Table (2, 2, false); + table.RowSpacing = 4; + table.ColumnSpacing = 4; + hbox.PackStart (table, false, false, 0); - Label label = new Label ("_Entry1"); - table.Attach (label, 0, 1, 0, 1); - Entry localEntry1 = new Entry(); - localEntry1.Text = entry1.Text; - table.Attach (localEntry1, 1, 2, 0, 1); - label.MnemonicWidget = localEntry1; + Label label = new Label ("_Entry1"); + table.Attach (label, 0, 1, 0, 1); + Entry localEntry1 = new Entry(); + localEntry1.Text = entry1.Text; + table.Attach (localEntry1, 1, 2, 0, 1); + label.MnemonicWidget = localEntry1; - label = new Label ("E_ntry2"); - table.Attach (label, 0, 1, 1, 2); - Entry localEntry2 = new Entry(); - localEntry2.Text = entry2.Text; - table.Attach (localEntry2, 1, 2, 1, 2); - label.MnemonicWidget = localEntry2; + label = new Label ("E_ntry2"); + table.Attach (label, 0, 1, 1, 2); + Entry localEntry2 = new Entry(); + localEntry2.Text = entry2.Text; + table.Attach (localEntry2, 1, 2, 1, 2); + label.MnemonicWidget = localEntry2; - hbox.ShowAll (); + hbox.ShowAll (); - ResponseType response = (ResponseType) dialog.Run (); + ResponseType response = (ResponseType) dialog.Run (); - if (response == ResponseType.Ok) - { - entry1.Text = localEntry1.Text; - entry2.Text = localEntry2.Text; - } + if (response == ResponseType.Ok) + { + entry1.Text = localEntry1.Text; + entry2.Text = localEntry2.Text; + } - dialog.Destroy (); + dialog.Hide (); + } } } } + diff --git a/sample/GtkDemo/DemoDrawingArea.cs b/sample/GtkDemo/DemoDrawingArea.cs index 1d25e47d1..90961c3eb 100644 --- a/sample/GtkDemo/DemoDrawingArea.cs +++ b/sample/GtkDemo/DemoDrawingArea.cs @@ -22,32 +22,29 @@ * to clear the area. */ - using System; - using Gtk; using Gdk; -namespace GtkDemo { - public class DemoDrawingArea +namespace GtkDemo +{ + public class DemoDrawingArea : Gtk.Window { - private Gtk.Window window; private static Pixmap pixmap = null; private static DrawingArea drawingArea; private static DrawingArea drawingArea1; - public DemoDrawingArea () + public DemoDrawingArea () : base ("Drawing Area") { - window = new Gtk.Window ("Drawing Area"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); - window.BorderWidth = 8; + this.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.BorderWidth = 8; VBox vbox = new VBox (false, 8); vbox.BorderWidth = 8; - window.Add (vbox); + this.Add (vbox); // Create the checkerboard area - Label label = new Label(null); + Label label = new Label (); label.Markup = "Checkerboard pattern"; vbox.PackStart (label, false, false, 0); @@ -55,10 +52,10 @@ namespace GtkDemo { frame.ShadowType = ShadowType.In; vbox.PackStart (frame, true, true, 0); - drawingArea = new DrawingArea(); + drawingArea = new DrawingArea (); // set a minimum size drawingArea.SetSizeRequest (100,100); - frame.Add(drawingArea); + frame.Add (drawingArea); drawingArea.ExposeEvent += new ExposeEventHandler (CheckerboardExpose); // Create the scribble area @@ -87,13 +84,14 @@ namespace GtkDemo { drawingArea1.Events = EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.PointerMotionMask | EventMask.PointerMotionHintMask; - window.ShowAll (); + this.ShowAll (); } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } private void CheckerboardExpose (object o, ExposeEventArgs args) @@ -122,7 +120,6 @@ namespace GtkDemo { color.Blue = 65535; gc2.RgbFgColor = color; - // Start redrawing the Checkerboard xcount = 0; i = Spacing; @@ -146,7 +143,6 @@ namespace GtkDemo { // return true because we've handled this event, so no // further processing is required. args.RetVal = true; - } private void ScribbleExpose (object o, ExposeEventArgs args) @@ -218,7 +214,6 @@ namespace GtkDemo { args.RetVal = true; } - // Draw a rectangle on the screen static void DrawBrush (double x, double y) { diff --git a/sample/GtkDemo/DemoEditableCells.cs b/sample/GtkDemo/DemoEditableCells.cs index 1b41a4127..6c7dadf0b 100644 --- a/sample/GtkDemo/DemoEditableCells.cs +++ b/sample/GtkDemo/DemoEditableCells.cs @@ -16,26 +16,23 @@ using System; using System.Collections; - using Gtk; namespace GtkDemo { - public class DemoEditableCells + public class DemoEditableCells : Gtk.Window { - private Gtk.Window window; private ListStore store; private TreeView treeView; private ArrayList articles; - public DemoEditableCells () + public DemoEditableCells () : base ("Color Selection") { - window = new Gtk.Window ("Color Selection"); - window.SetDefaultSize (320, 200); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.SetDefaultSize (320, 200); + this.DeleteEvent += new DeleteEventHandler (WindowDelete); VBox vbox = new VBox (false, 5); - window.Add (vbox); + this.Add (vbox); vbox.PackStart (new Label ("Shopping list (you can edit the cells!)"), false, false, 0); @@ -63,11 +60,9 @@ namespace GtkDemo button.Clicked += new EventHandler (RemoveItem); hbox.PackStart (button, true, true, 0); - window.ShowAll (); + this.ShowAll (); } - - private void AddColumns () { CellRendererText renderer; @@ -79,7 +74,6 @@ namespace GtkDemo treeView.AppendColumn ("Number", renderer, "text", (int) Column.Number); - // product column renderer = new CellRendererText (); renderer.Edited += new EditedHandler (TextCellEdited); @@ -91,7 +85,6 @@ namespace GtkDemo private void CreateModel () { - // create array articles = new ArrayList (); AddItems (); @@ -101,7 +94,6 @@ namespace GtkDemo // add items foreach (Item item in articles) store.AppendValues (item.Number, item.Product, item.Editable); - } private void AddItems () @@ -126,58 +118,42 @@ namespace GtkDemo private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } - // FIXME: This is ugly. - // Figure out why the following line doesn't work - // Console.WriteLine ("articles[i] {0}", articles[i].Number); - // the code would definitely look better if I havent to do the - // following midle step to get the Number. - // foo.Number = Convert.ToInt32(args.NewText); - //, Figure out why I'm not catching the execptions.. private void NumberCellEdited (object o, EditedArgs args) { int i; + Item foo; + try { - i = Convert.ToInt32(args.Path); - } - catch (Exception e) + i = Convert.ToInt32 (args.Path); + foo = (Item) articles[i]; + foo.Number = int.Parse (args.NewText); + } + catch (Exception e) { - Console.WriteLine ("Exeception {0}",e); - return; // This return should exit the callback but it doesn't - } - Console.WriteLine ("--NUMBER--1"); -// //Console.WriteLine ("Path {0}", args.Path); -// //Console.WriteLine ("NewText {0}", args.NewText); -// //Console.WriteLine ("articles[i] {0}",articles[i]); - Item foo = (Item) articles[i]; -// //Console.WriteLine ("foo.Number {0}", foo.Number); -// //Console.WriteLine (""); - foo.Number = Convert.ToInt32(args.NewText); - TreeIter iter = new TreeIter (); -// // How the hell do I assing the column !!! - store.GetIterFromString(out iter, args.Path); -// store.SetValue(iter, (int) Column.Number, foo.Number); + Console.WriteLine (e.ToString ()); + return; + } + + TreeIter iter; + store.GetIterFromString (out iter, args.Path); + store.SetValue (iter, (int) Column.Number, foo.Number); } private void TextCellEdited (object o, EditedArgs args) { - int i = Convert.ToInt32(args.Path); - // Console.WriteLine ("--PRODUCT--"); - // Console.WriteLine ("Path {0}", args.Path); - // Console.WriteLine ("NewText {0}", args.NewText); - // Console.WriteLine ("articles[i] {0}",articles[i]); + int i = int.Parse (args.Path); Item foo = (Item) articles[i]; - // Console.WriteLine ("foo.Product {0}", foo.Product); - // Console.WriteLine (""); foo.Product = args.NewText; - TreeIter iter = new TreeIter (); - store.GetIterFromString(out iter, args.Path); - store.SetValue(iter, (int) Column.Product, foo.Product); + TreeIter iter; + store.GetIterFromString (out iter, args.Path); + store.SetValue (iter, (int) Column.Product, foo.Product); } private void AddItem (object o, EventArgs args) @@ -194,10 +170,9 @@ namespace GtkDemo if (treeView.Selection.GetSelected (out model, out iter)) { - TreePath path = store.GetPath (iter); + int position = int.Parse (store.GetPath (iter).ToString ()); store.Remove (ref iter); - //articles.RemoveAt (path.Indices[0]); - + articles.RemoveAt (position); } } } @@ -229,7 +204,7 @@ namespace GtkDemo private string ProductItem; private bool EditableItem; - public Item (int number , string product, bool editable) + public Item (int number, string product, bool editable) { NumberItem = number; ProductItem = product; diff --git a/sample/GtkDemo/DemoImages.cs b/sample/GtkDemo/DemoImages.cs index 2798fb7df..891113cc6 100644 --- a/sample/GtkDemo/DemoImages.cs +++ b/sample/GtkDemo/DemoImages.cs @@ -31,21 +31,21 @@ using System.IO; using Gtk; using Gdk; -namespace GtkDemo { - public class DemoImages +namespace GtkDemo +{ + public class DemoImages : Gtk.Window { - private Gtk.Window window; private static Gtk.Image progressiveImage; private VBox vbox; - public DemoImages () + + public DemoImages () : base ("images") { - window = new Gtk.Window ("Images"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); - window.BorderWidth = 8; + this.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.BorderWidth = 8; vbox = new VBox (false, 8); vbox.BorderWidth = 8; - window.Add (vbox); + this.Add (vbox); Gtk.Label label = new Gtk.Label ("Image loaded from a file"); label.UseMarkup = true; @@ -104,13 +104,14 @@ namespace GtkDemo { vbox.PackStart (button, false, false, 0); button.Toggled += new EventHandler (ToggleSensitivity); - window.ShowAll (); + this.ShowAll (); } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } private void ToggleSensitivity (object o, EventArgs args) @@ -122,7 +123,6 @@ namespace GtkDemo { widget.Sensitive = !widget.Sensitive; } - private uint timeout_id; private void StartProgressiveLoading () { @@ -149,17 +149,16 @@ namespace GtkDemo { return true; } - static void ProgressivePreparedCallback (object obj, EventArgs args) + static void ProgressivePreparedCallback (object obj, EventArgs args) { Gdk.Pixbuf pixbuf = pixbufLoader.Pixbuf; pixbuf.Fill (0xaaaaaaff); progressiveImage.FromPixbuf = pixbuf; } - static void ProgressiveUpdatedCallback (object obj, AreaUpdatedArgs args) + static void ProgressiveUpdatedCallback (object obj, AreaUpdatedArgs args) { } - } } diff --git a/sample/GtkDemo/DemoItemFactory.cs b/sample/GtkDemo/DemoItemFactory.cs index 12cfcfe40..c119c1743 100644 --- a/sample/GtkDemo/DemoItemFactory.cs +++ b/sample/GtkDemo/DemoItemFactory.cs @@ -21,24 +21,22 @@ using Gdk; namespace GtkDemo { - public class DemoItemFactory + public class DemoItemFactory : Gtk.Window { - private Gtk.Window window; - - public DemoItemFactory () + public DemoItemFactory () : base ("Demo Item Factory") { - window = new Gtk.Window (null); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.DeleteEvent += new DeleteEventHandler (WindowDelete); Gtk.AccelGroup accelGroup = new Gtk.AccelGroup (); //STUCK OUCH !!!! - window.ShowAll (); + this.ShowAll (); } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } } } diff --git a/sample/GtkDemo/DemoListStore.cs b/sample/GtkDemo/DemoListStore.cs index ca3db28a9..28280ac58 100644 --- a/sample/GtkDemo/DemoListStore.cs +++ b/sample/GtkDemo/DemoListStore.cs @@ -21,27 +21,26 @@ using Gtk; namespace GtkDemo { - - public class DemoListStore + public class DemoListStore : Gtk.Window { - private Window window; ListStore store; - public DemoListStore (){ - window = new Window ("ListStore Demo"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); + + public DemoListStore () : base ("ListStore Demo") + { + this.DeleteEvent += new DeleteEventHandler (WindowDelete); VBox vbox = new VBox (false, 8); vbox.BorderWidth = 8; - window.Add (vbox); + this.Add (vbox); - vbox.PackStart(new Label ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though)."), false, false, 0); + vbox.PackStart (new Label ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though)."), false, false, 0); ScrolledWindow scrolledWindow = new ScrolledWindow (); scrolledWindow.ShadowType = ShadowType.EtchedIn; scrolledWindow.SetPolicy (PolicyType.Automatic, PolicyType.Automatic); vbox.PackStart (scrolledWindow, true, true, 0); // create model - CreateModel(); + CreateModel (); // create tree view TreeView treeView = new TreeView (store); @@ -51,21 +50,18 @@ namespace GtkDemo scrolledWindow.Add (treeView); // finish & show - window.SetDefaultSize (650, 400); - window.ShowAll (); + this.SetDefaultSize (650, 400); + this.ShowAll (); } - //FIXME: Finish implementing this function, I don't know - // why it doesn't work. private void ItemToggled (object o, ToggledArgs args) { - Gtk.TreeIter iter; - if (store.GetIterFromString(out iter, args.Path)) + if (store.GetIterFromString (out iter, args.Path)) { - bool val = (bool) store.GetValue(iter, 0); - Console.WriteLine("toggled {0} with value {1}", args.Path, val); - store.SetValue(iter, 0, !val); + bool val = (bool) store.GetValue (iter, 0); + Console.WriteLine ("toggled {0} with value {1}", args.Path, val); + store.SetValue (iter, 0, !val); } } @@ -74,37 +70,36 @@ namespace GtkDemo // column for fixed toggles CellRendererToggle rendererToggle = new CellRendererToggle (); rendererToggle.Toggled += new ToggledHandler (ItemToggled); - TreeViewColumn column = new TreeViewColumn("Fixed", rendererToggle, "active", 0); + TreeViewColumn column = new TreeViewColumn ("Fixed", rendererToggle, "active", 0); rendererToggle.Active = true; rendererToggle.Activatable = true; rendererToggle.Visible = true; // set this column to a fixed sizing (of 50 pixels) column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 50; - treeView.AppendColumn(column); + treeView.AppendColumn (column); // column for bug numbers CellRendererText rendererText = new CellRendererText (); - column = new TreeViewColumn("Bug number", rendererText, "text", ColumnNumber.Number); + column = new TreeViewColumn ("Bug number", rendererText, "text", ColumnNumber.Number); column.SortColumnId = (int) ColumnNumber.Number; - treeView.AppendColumn(column); + treeView.AppendColumn (column); // column for severities rendererText = new CellRendererText (); - column = new TreeViewColumn("Severity", rendererText, "text", ColumnNumber.Severity); + column = new TreeViewColumn ("Severity", rendererText, "text", ColumnNumber.Severity); column.SortColumnId = (int) ColumnNumber.Severity; treeView.AppendColumn(column); // column for description rendererText = new CellRendererText (); - column = new TreeViewColumn("Description", rendererText, "text", ColumnNumber.Description); + column = new TreeViewColumn ("Description", rendererText, "text", ColumnNumber.Description); column.SortColumnId = (int) ColumnNumber.Description; - treeView.AppendColumn(column); - + treeView.AppendColumn (column); } - private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } private void CreateModel () @@ -119,11 +114,13 @@ namespace GtkDemo store.AppendValues(bug.Fixed, bug.Number, bug.Severity, - bug.Description);} + bug.Description); + } } - //FIXME: Insted of using numbert conver enum to array using - // GetValues and then ge the Length Property + + // FIXME: Instead of using number convert enum to array using + // GetValues and then get the Length Property public enum ColumnNumber { Fixed, @@ -132,8 +129,6 @@ namespace GtkDemo Description, } - - private static Bug[] bugs = { new Bug ( false, 60482, "Normal", "scrollable notebooks and hidden tabs"), @@ -153,24 +148,20 @@ namespace GtkDemo }; } - public class Bug { public bool Fixed; public int Number; public string Severity; - public string Description; + public string Description; - public Bug ( bool status, - int number, - string severity, - string description) - { - Fixed = status; - Number = number; - Severity = severity; - Description = description; - } + public Bug (bool status, int number, string severity, + string description) + { + Fixed = status; + Number = number; + Severity = severity; + Description = description; + } } - } diff --git a/sample/GtkDemo/DemoMain.cs b/sample/GtkDemo/DemoMain.cs index 3b203c5d2..ed248225a 100644 --- a/sample/GtkDemo/DemoMain.cs +++ b/sample/GtkDemo/DemoMain.cs @@ -18,8 +18,8 @@ namespace GtkDemo public class DemoMain { private Gtk.Window window; - private TextBuffer infoBuffer = new TextBuffer(null); - private TextBuffer sourceBuffer = new TextBuffer(null); + private TextBuffer infoBuffer = new TextBuffer (null); + private TextBuffer sourceBuffer = new TextBuffer (null); private TreeView treeView; private TreeStore store; public static void Main (string[] args) @@ -32,8 +32,8 @@ namespace GtkDemo public DemoMain () { SetupDefaultIcon (); - window = new Gtk.Window ("Gtk# Code Demos"); - window.SetDefaultSize (600,400); + window = new Gtk.Window ("Gtk# Code Demos"); + window.SetDefaultSize (600,400); window.DeleteEvent += new DeleteEventHandler (WindowDelete); HBox hbox = new HBox (false, 0); @@ -55,22 +55,21 @@ namespace GtkDemo window.ShowAll (); } - private void LoadFile(string filename) + private void LoadFile (string filename) { - - Stream file = File.OpenRead(filename); - StreamReader sr = new StreamReader(file); - string s = sr.ReadToEnd(); - sr.Close(); - file.Close(); + Stream file = File.OpenRead (filename); + StreamReader sr = new StreamReader (file); + string s = sr.ReadToEnd (); + sr.Close (); + file.Close (); infoBuffer.Text = filename; sourceBuffer.Text = s; - Fontify(); + Fontify (); } - private void Fontify() + private void Fontify () { } @@ -84,10 +83,7 @@ namespace GtkDemo // The gtk-logo-rgb icon has a white background, make it transparent Pixbuf transparent = pixbuf.AddAlpha (true, 0xff, 0xff, 0xff); - Gdk.Pixbuf[] list = new Gdk.Pixbuf [1]; - list[0] = transparent; - - Gtk.Window.DefaultIconList = list; + Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {transparent}; } } @@ -119,7 +115,6 @@ namespace GtkDemo FontDescription fontDescription = FontDescription.FromString ("Courier 12"); textView.ModifyFont (fontDescription); textView.WrapMode = Gtk.WrapMode.None; - } else { @@ -132,18 +127,17 @@ namespace GtkDemo return scrolledWindow; } - private TreeView CreateTree () - { - treeView = new TreeView (); - return treeView; + { + treeView = new TreeView (); + return treeView; } private TreeStore FillTree () { store = new TreeStore (typeof (string)); - store.AppendValues ("Application Window (5% complete)"); + store.AppendValues ("Application Window (75% complete)"); store.AppendValues ("Button Boxes"); store.AppendValues ("Change Display"); store.AppendValues ("Color Selector"); @@ -158,16 +152,15 @@ namespace GtkDemo store.AppendValues ("Stock Item and Icon Browser (10% complete)"); store.AppendValues ("Text Widget (95% complete)"); TreeIter iter = store.AppendValues ("Tree View"); - store.AppendValues (iter, "Editable Cells (buggy)"); + store.AppendValues (iter, "Editable Cells"); store.AppendValues (iter, "List Store"); - store.AppendValues (iter, "Tree Store (95% complete)"); + store.AppendValues (iter, "Tree Store"); return store; } private void OnTreeChanged (object o, EventArgs args) - { - + { TreeIter iter; TreeModel model; @@ -176,67 +169,66 @@ namespace GtkDemo TreePath path; path = store.GetPath (iter); - switch (path.ToString()) { - - case "0": - LoadFile ("DemoApplicationWindow.cs"); - break; - case "1": - LoadFile ("DemoButtonBox.cs"); - break; - case "2": - // - break; - case "3": - LoadFile ("DemoColorSelection.cs"); - break; - case "4": - LoadFile ("DemoDialog.cs"); - break; - case "5": - LoadFile ("DemoDrawingArea.cs"); - break; - case "6": - LoadFile ("DemoImages.cs"); - break; - case "7": - LoadFile ("DemoItemFactory.cs"); - break; - case "8": - LoadFile ("DemoMenus.cs"); - break; - case "9": - LoadFile ("DemoPanes.cs"); - break; - case "10": - LoadFile ("DemoPixbuf.cs"); - break; - case "11": - LoadFile ("DemoSizeGroup.cs"); - break; - case "12": - LoadFile ("DemoStockBrowser.cs"); - break; - case "13": - LoadFile ("DemoTextView.cs"); - break; - case "14": - // do nothing - break; - case "14:0": - LoadFile ("DemoEditableCells.cs"); - break; - case "14:1": - LoadFile ("DemoListStore.cs"); - break; - case "14:2": - LoadFile ("DemoTreeStore.cs"); - break; - default: - break; - } + switch (path.ToString()) { + case "0": + LoadFile ("DemoApplicationWindow.cs"); + break; + case "1": + LoadFile ("DemoButtonBox.cs"); + break; + case "2": + // + break; + case "3": + LoadFile ("DemoColorSelection.cs"); + break; + case "4": + LoadFile ("DemoDialog.cs"); + break; + case "5": + LoadFile ("DemoDrawingArea.cs"); + break; + case "6": + LoadFile ("DemoImages.cs"); + break; + case "7": + LoadFile ("DemoItemFactory.cs"); + break; + case "8": + LoadFile ("DemoMenus.cs"); + break; + case "9": + LoadFile ("DemoPanes.cs"); + break; + case "10": + LoadFile ("DemoPixbuf.cs"); + break; + case "11": + LoadFile ("DemoSizeGroup.cs"); + break; + case "12": + LoadFile ("DemoStockBrowser.cs"); + break; + case "13": + LoadFile ("DemoTextView.cs"); + break; + case "14": + // do nothing + break; + case "14:0": + LoadFile ("DemoEditableCells.cs"); + break; + case "14:1": + LoadFile ("DemoListStore.cs"); + break; + case "14:2": + LoadFile ("DemoTreeStore.cs"); + break; + default: + break; } + } } private void OnRowActivated (object o, RowActivatedArgs args) @@ -298,9 +290,9 @@ namespace GtkDemo break; default: break; - } + } } - + private void WindowDelete (object o, DeleteEventArgs args) { Application.Quit (); diff --git a/sample/GtkDemo/DemoMenus.cs b/sample/GtkDemo/DemoMenus.cs index b5aa8d37e..b1421a01f 100644 --- a/sample/GtkDemo/DemoMenus.cs +++ b/sample/GtkDemo/DemoMenus.cs @@ -41,25 +41,21 @@ // point on the right side using System; - using Gtk; namespace GtkDemo { - public class DemoMenus + public class DemoMenus : Gtk.Window { - private Gtk.Window window; - - public DemoMenus () + public DemoMenus () : base ("Menus") { - window = new Window ("Menus"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.DeleteEvent += new DeleteEventHandler (WindowDelete); AccelGroup accel_group = new AccelGroup (); - window.AddAccelGroup (accel_group); + this.AddAccelGroup (accel_group); VBox box1 = new VBox (false, 0); - window.Add (box1); + this.Add (box1); MenuBar menubar = new MenuBar (); box1.PackStart (menubar, false, false, 0); @@ -128,7 +124,7 @@ namespace GtkDemo close_button.CanDefault = true; close_button.GrabDefault (); - window.ShowAll (); + this.ShowAll (); } private Menu Create_Menu (int depth, bool tearoff) @@ -170,14 +166,15 @@ namespace GtkDemo private void Close_Button (object o, EventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } } } diff --git a/sample/GtkDemo/DemoPanes.cs b/sample/GtkDemo/DemoPanes.cs index 8f406562e..96fe0cd29 100644 --- a/sample/GtkDemo/DemoPanes.cs +++ b/sample/GtkDemo/DemoPanes.cs @@ -22,14 +22,12 @@ using System; - using Gtk; namespace GtkDemo { - public class DemoPanes + public class DemoPanes : Gtk.Window { - private Window window; private VPaned vpaned; private HPaned top; private Frame left; @@ -45,14 +43,14 @@ namespace GtkDemo private CheckButton resizeBottom; private CheckButton shrinkBottom; private Button button; - public DemoPanes () + + public DemoPanes () : base ("Panes") { - window = new Window ("Panes"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); - window.BorderWidth = 0; + this.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.BorderWidth = 0; VBox vbox = new VBox (false, 0); - window.Add (vbox); + this.Add (vbox); vpaned = new VPaned (); vbox.PackStart (vpaned, true, true, 0); @@ -144,39 +142,37 @@ namespace GtkDemo shrinkBottom.Active = true; shrinkBottom.Toggled += new EventHandler (BottomCB); - window.ShowAll (); + this.ShowAll (); } - private void LeftCB (object o, EventArgs args) + private void LeftCB (object o, EventArgs args) { - top.Remove(left); - top.Pack1(left, resizeLeft.Active, shrinkLeft.Active); + top.Remove (left); + top.Pack1 (left, resizeLeft.Active, shrinkLeft.Active); } - - private void RightCB (object o, EventArgs args) + private void RightCB (object o, EventArgs args) { - top.Remove(right); - top.Pack2(right, resizeRight.Active, shrinkRight.Active); + top.Remove (right); + top.Pack2 (right, resizeRight.Active, shrinkRight.Active); } - private void TopCB (object o, EventArgs args) + private void TopCB (object o, EventArgs args) { - vpaned.Remove(top); - vpaned.Pack1(top, resizeTop.Active, shrinkTop.Active); + vpaned.Remove (top); + vpaned.Pack1 (top, resizeTop.Active, shrinkTop.Active); } - private void BottomCB (object o, EventArgs args) + private void BottomCB (object o, EventArgs args) { - vpaned.Remove(bottom); - vpaned.Pack2(bottom, resizeBottom.Active, shrinkBottom.Active); + vpaned.Remove (bottom); + vpaned.Pack2 (bottom, resizeBottom.Active, shrinkBottom.Active); } - - private void WindowDelete (object o, DeleteEventArgs args) + private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); } } } diff --git a/sample/GtkDemo/DemoPixbuf.cs b/sample/GtkDemo/DemoPixbuf.cs index dfec980b9..7b7684415 100644 --- a/sample/GtkDemo/DemoPixbuf.cs +++ b/sample/GtkDemo/DemoPixbuf.cs @@ -29,63 +29,58 @@ namespace GtkDemo { public class DemoPixbuf : Gtk.Window -{ - - const int FrameDelay = 50; - const int CycleLen = 60; - const string BackgroundName = "images/background.jpg"; - string [] ImageNames = { - "images/apple-red.png", - "images/gnome-applets.png", - "images/gnome-calendar.png", - "images/gnome-foot.png", - "images/gnome-gmush.png", - "images/gnome-gimp.png", - "images/gnome-gsame.png", - "images/gnu-keys.png" - }; + { + const int FrameDelay = 50; + const int CycleLen = 60; + const string BackgroundName = "images/background.jpg"; - // current frame - Pixbuf frame; - int frameNum; - - // background image - Pixbuf background; - int backWidth, backHeight; - - // images - Pixbuf[] images; - - // drawing area - DrawingArea drawingArea; - - - - - string FindFile (string name) - { - return name; - } - - // Loads the images for the demo - void LoadPixbuf () - { - background = new Pixbuf (FindFile (BackgroundName)); - - backWidth = background.Width; - backHeight = background.Height; - - images = new Pixbuf[ImageNames.Length]; + string [] ImageNames = { + "images/apple-red.png", + "images/gnome-applets.png", + "images/gnome-calendar.png", + "images/gnome-foot.png", + "images/gnome-gmush.png", + "images/gnome-gimp.png", + "images/gnome-gsame.png", + "images/gnu-keys.png" + }; - for (int i = 0; i < ImageNames.Length; i++) - images[i] = new Pixbuf (FindFile (ImageNames[i])); - } + // current frame + Pixbuf frame; + int frameNum; + + // background image + Pixbuf background; + int backWidth, backHeight; + // images + Pixbuf[] images; - // Expose callback for the drawing area - void Expose (object o, ExposeEventArgs args) - { + // drawing area + DrawingArea drawingArea; + string FindFile (string name) + { + return name; + } + + // Loads the images for the demo + void LoadPixbuf () + { + background = new Pixbuf (FindFile (BackgroundName)); + + backWidth = background.Width; + backHeight = background.Height; + + images = new Pixbuf[ImageNames.Length]; + + for (int i = 0; i < ImageNames.Length; i++) + images[i] = new Pixbuf (FindFile (ImageNames[i])); + } + + // Expose callback for the drawing area + void Expose (object o, ExposeEventArgs args) + { EventExpose ev = args.Event; Widget widget = (Widget) o; Gdk.Rectangle area = ev.Area; @@ -98,120 +93,116 @@ namespace GtkDemo Gdk.PixbufAlphaMode.Full, 8, RgbDither.Normal, 100, 100); - - - } + } + // timeout handler to regenerate the frame + bool timeout () + { + background.CopyArea (0, 0, backWidth, backHeight, frame, 0, 0); - // timeout handler to regenerate the frame - bool timeout () - { - background.CopyArea (0, 0, backWidth, backHeight, frame, 0, 0); + double f = (double) (frameNum % CycleLen) / CycleLen; - double f = (double) (frameNum % CycleLen) / CycleLen; + int xmid = backWidth / 2; + int ymid = backHeight / 2; - int xmid = backWidth / 2; - int ymid = backHeight / 2; + double radius = Math.Min (xmid, ymid) / 2; - double radius = Math.Min (xmid, ymid) / 2; + for (int i = 0; i < images.Length; i++) { + double ang = 2 * Math.PI * i / images.Length - f * 2 * + Math.PI; - for (int i = 0; i < images.Length; i++) { - double ang = 2 * Math.PI * i / images.Length - f * 2 * - Math.PI; + int iw = images[i].Width; + int ih = images[i].Height; - int iw = images[i].Width; - int ih = images[i].Height; + double r = radius + (radius / 3) * Math.Sin (f * 2 * + Math.PI); - double r = radius + (radius / 3) * Math.Sin (f * 2 * - Math.PI); - - int xpos = (int) Math.Floor (xmid + r * Math.Cos (ang) - - iw / 2 + 0.5); - int ypos = (int) Math.Floor (ymid + r * Math.Sin (ang) - - ih / 2 + 0.5); + int xpos = (int) Math.Floor (xmid + r * Math.Cos (ang) - + iw / 2 + 0.5); + int ypos = (int) Math.Floor (ymid + r * Math.Sin (ang) - + ih / 2 + 0.5); - double k = (i % 2 == 1) ? Math.Sin (f * 2 * Math.PI) : - Math.Cos (f * 2 * Math.PI); - k = 2 * k * k; - k = Math.Max (0.25, k); + double k = (i % 2 == 1) ? Math.Sin (f * 2 * Math.PI) : + Math.Cos (f * 2 * Math.PI); + k = 2 * k * k; + k = Math.Max (0.25, k); - Rectangle r1, r2, dest; + Rectangle r1, r2, dest; - r1 = new Rectangle (xpos, ypos,(int) (iw * k), - (int) (ih * k)); + r1 = new Rectangle (xpos, ypos,(int) (iw * k), + (int) (ih * k)); -/* FIXME: Why is that code not working (in the original gtk-demo it works + /* FIXME: Why is that code not working (in the original gtk-demo it works - r2 = new Rectangle (0, 0, backWidth, backHeight); + r2 = new Rectangle (0, 0, backWidth, backHeight); - dest = new Rectangle (0, 0, 0, 0); - r1.Intersect (r2, dest); + dest = new Rectangle (0, 0, 0, 0); + r1.Intersect (r2, dest); - images[i].Composite (frame, dest.x, dest.y, dest.width, - dest.height, xpos, ypos, k, k, - InterpType.Nearest, (int) ((i % 2 == 1) - ? Math.Max (127, Math.Abs (255 * Math.Sin (f * - 2 * Math.PI))) - : Math.Max (127, Math.Abs (255 * Math.Cos (f * - 2 * Math.PI))))); -*/ - images[i].Composite (frame, r1.X, r1.Y, r1.Width, - r1.Height, xpos, ypos, k, k, - InterpType.Nearest, (int) ((i % 2 == 1) - ? Math.Max (127, Math.Abs (255 * Math.Sin (f * - 2 * Math.PI))) - : Math.Max (127, Math.Abs (255 * Math.Cos (f * - 2 * Math.PI))))); - } + images[i].Composite (frame, dest.x, dest.y, dest.width, + dest.height, xpos, ypos, k, k, + InterpType.Nearest, (int) ((i % 2 == 1) + ? Math.Max (127, Math.Abs (255 * Math.Sin (f * + 2 * Math.PI))) + : Math.Max (127, Math.Abs (255 * Math.Cos (f * + 2 * Math.PI))))); + */ + images[i].Composite (frame, r1.X, r1.Y, r1.Width, + r1.Height, xpos, ypos, k, k, + InterpType.Nearest, (int) ((i % 2 == 1) + ? Math.Max (127, Math.Abs (255 * Math.Sin (f * + 2 * Math.PI))) + : Math.Max (127, Math.Abs (255 * Math.Cos (f * + 2 * Math.PI))))); + } - drawingArea.QueueDraw (); - frameNum++; + drawingArea.QueueDraw (); + frameNum++; - return true; - } - - - private Gtk.Window window; - - public DemoPixbuf () : base ("Gdk Pixbuf Demo") - { - //window = new DemoPixbuf (); - //window.DeleteEvent += new DeleteEventHandler (WindowDelete); - - try { - LoadPixbuf (); - } catch (Exception e) { - MessageDialog md = new MessageDialog (this, - DialogFlags.DestroyWithParent, - MessageType.Error, - ButtonsType.Close, - "Error: \n" + e.Message); - md.Run (); - - throw; + return true; } - frame = new Pixbuf (Colorspace.Rgb, true, 8, backWidth, - backHeight); + public DemoPixbuf () : base ("Gdk Pixbuf Demo") + { + this.DeleteEvent += new DeleteEventHandler (OnWindowDelete); - drawingArea = new DrawingArea (); - drawingArea.ExposeEvent += new ExposeEventHandler (Expose); + try + { + LoadPixbuf (); + } catch (Exception e) + { + using (MessageDialog md = new MessageDialog (this, + DialogFlags.DestroyWithParent, + MessageType.Error, + ButtonsType.Close, + "Error: \n" + e.Message)) { + md.Run (); + md.Hide (); + } - Add (drawingArea); - GLib.Timeout.Add (FrameDelay, new GLib.TimeoutHandler(timeout)); + throw; + } - this.SetDefaultSize (backWidth, backHeight); -// this.Resizable = false; - ShowAll (); + frame = new Pixbuf (Colorspace.Rgb, true, 8, backWidth, + backHeight); + + drawingArea = new DrawingArea (); + drawingArea.ExposeEvent += new ExposeEventHandler (Expose); + + Add (drawingArea); + GLib.Timeout.Add (FrameDelay, new GLib.TimeoutHandler(timeout)); + + this.SetDefaultSize (backWidth, backHeight); + // this.Resizable = false; + ShowAll (); + } + + void OnWindowDelete (object obj, DeleteEventArgs args) + { + this.Hide (); + this.Destroy (); + args.RetVal = true; + } } - - - static void windowDelete (object obj, DeleteEventArgs args) - { - Application.Quit (); - } - - -} } diff --git a/sample/GtkDemo/DemoSizeGroup.cs b/sample/GtkDemo/DemoSizeGroup.cs index 6b08ceb73..191717352 100644 --- a/sample/GtkDemo/DemoSizeGroup.cs +++ b/sample/GtkDemo/DemoSizeGroup.cs @@ -22,24 +22,21 @@ */ using System; - using Gtk; namespace GtkDemo { - public class DemoSizeGroup + public class DemoSizeGroup : Dialog { - private Dialog window; private SizeGroup sizeGroup; public DemoSizeGroup () { - window = new Dialog (); - window.Title = "Sized groups"; - window.Resizable = false; + this.Title = "Size groups"; + this.Resizable = false; VBox vbox = new VBox (false, 5); - window.VBox.PackStart (vbox, true, true, 0); + this.VBox.PackStart (vbox, true, true, 0); vbox.BorderWidth = 5; sizeGroup = new SizeGroup (SizeGroupMode.Horizontal); @@ -81,10 +78,10 @@ namespace GtkDemo checkButton.Toggled += new EventHandler (ButtonToggleCb); Button CloseButton = new Button (Stock.Close); - window.AddActionWidget (CloseButton, 5); - window.Response += new ResponseHandler (ResponseCallback); + this.AddActionWidget (CloseButton, ResponseType.Close); + this.Response += new ResponseHandler (ResponseCallback); - window.ShowAll (); + this.ShowAll (); } // Convenience function to create an option menu holding a number of strings @@ -147,11 +144,11 @@ namespace GtkDemo } private void ResponseCallback (object obj, ResponseArgs args) - - { - if (((int) args.ResponseId) == 5) { - window.Hide (); - window.Destroy ();} - } + { + if ((args.ResponseId) == ResponseType.Close) { + this.Hide (); + this.Destroy (); + } + } } } diff --git a/sample/GtkDemo/DemoStockBrowser.cs b/sample/GtkDemo/DemoStockBrowser.cs index 0cf249d94..b7118bc28 100644 --- a/sample/GtkDemo/DemoStockBrowser.cs +++ b/sample/GtkDemo/DemoStockBrowser.cs @@ -6,24 +6,20 @@ // (C) 2003 Ximian, Inc. using System; - using Gtk; namespace GtkDemo { - public class DemoStockBrowser + public class DemoStockBrowser : Gtk.Window { - private Gtk.Window window; - - public DemoStockBrowser () + public DemoStockBrowser () : base ("Stock Item Browser Demo") { - window = new Gtk.Window ("Stock Item Browser Demo"); - window.SetDefaultSize (600, 400); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); - window.BorderWidth = 8; + this.SetDefaultSize (600, 400); + this.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.BorderWidth = 8; HBox hbox = new HBox (false, 8); - window.Add (hbox); + this.Add (hbox); ScrolledWindow scrolledWindow = new ScrolledWindow (null, null); scrolledWindow.SetPolicy (PolicyType.Never, PolicyType.Automatic); @@ -40,16 +36,9 @@ namespace GtkDemo Frame frame = new Frame (); hbox.PackStart (frame, true, true, 0); - window.ShowAll (); + this.ShowAll (); } -// private TreeModel CreateModel () -// { -// ListStore store; -// TreeModel model = new TreeModel (); -// return model; -// } - private ListStore CreateStore () { // image, name, label, accel @@ -66,8 +55,9 @@ namespace GtkDemo private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } } } diff --git a/sample/GtkDemo/DemoTextView.cs b/sample/GtkDemo/DemoTextView.cs index c559c80d5..01fc07823 100644 --- a/sample/GtkDemo/DemoTextView.cs +++ b/sample/GtkDemo/DemoTextView.cs @@ -13,8 +13,6 @@ * formatting features. */ - - using System; using System.IO; @@ -23,21 +21,20 @@ using Gtk; namespace GtkDemo { - public class DemoTextView + public class DemoTextView : Gtk.Window { - private Gtk.Window window; TextView view1; TextView view2; - public DemoTextView () + + public DemoTextView () : base ("TextView Demo") { - window = new Gtk.Window ("TextView Demo"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); - window.SetDefaultSize (450,450); - window.BorderWidth = 0; + this.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.SetDefaultSize (450,450); + this.BorderWidth = 6; VPaned vpaned = new VPaned (); vpaned.BorderWidth = 5; - window.Add (vpaned); + this.Add (vpaned); /* For convenience, we just use the autocreated buffer from * the first text view; you could also create the buffer @@ -66,14 +63,15 @@ namespace GtkDemo vpaned.ShowAll(); - window.ShowAll (); - + this.ShowAll (); } + private TextChildAnchor buttonAnchor; private TextChildAnchor menuAnchor; private TextChildAnchor scaleAnchor; private TextChildAnchor animationAnchor; private TextChildAnchor entryAnchor; + private void AttachWidgets (TextView textView) { Button button = new Button ("Click Me"); @@ -84,11 +82,11 @@ namespace GtkDemo OptionMenu option = new OptionMenu (); Menu menu = new Menu (); MenuItem menuItem = new MenuItem ("Option 1"); - menu.Append(menuItem); + menu.Append (menuItem); menuItem = new MenuItem ("Option 2"); - menu.Append(menuItem); + menu.Append (menuItem); menuItem = new MenuItem ("Option 3"); - menu.Append(menuItem); + menu.Append (menuItem); option.Menu = menu; textView.AddChildAtAnchor (option, menuAnchor); menu.ShowAll (); @@ -106,7 +104,6 @@ namespace GtkDemo Entry entry = new Entry (); textView.AddChildAtAnchor (entry, entryAnchor); image.ShowAll (); - } private void CreateTags (TextBuffer buffer) @@ -130,128 +127,128 @@ namespace GtkDemo * gtk_text_tag_set_priority(). */ - TextTag tag = new TextTag("heading"); + TextTag tag = new TextTag ("heading"); tag.Weight = Pango.Weight.Bold; tag.Size = (int) Pango.Scale.PangoScale * 15; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("italic"); + tag = new TextTag ("italic"); tag.Style = Pango.Style.Italic; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("bold"); + tag = new TextTag ("bold"); tag.Weight = Pango.Weight.Bold; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("big"); + tag = new TextTag ("big"); tag.Size = (int) Pango.Scale.PangoScale * 20; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("xx-small"); + tag = new TextTag ("xx-small"); tag.Scale = Pango.Scale.XX_Small; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("x-large"); + tag = new TextTag ("x-large"); tag.Scale = Pango.Scale.X_Large; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("monospace"); + tag = new TextTag ("monospace"); tag.Family = "monospace"; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("blue_foreground"); + tag = new TextTag ("blue_foreground"); tag.Foreground = "blue"; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("red_background"); + tag = new TextTag ("red_background"); tag.Background = "red"; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); int gray50_width = 2; int gray50_height = 2; string gray50_bits = new string ((char) 0x02, (char) 0x01); // Pixmap stipple = Pixmap.CreateFromData (null, (string) gray50_bits, gray50_width, gray50_height, 16, Color.Zero, Color.Zero); - tag = new TextTag("background_stipple"); + tag = new TextTag ("background_stipple"); // tag.BackgroundStipple = stipple; // Cannot convert type 'Gdk.Bitmap' to 'Gdk.Pixmap' - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("foreground_stipple"); + tag = new TextTag ("foreground_stipple"); // Cannot convert type 'Gdk.Bitmap' to 'Gdk.Pixmap' // tag.ForegroundStipple = stipple; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("big_gap_before_line"); + tag = new TextTag ("big_gap_before_line"); tag.PixelsAboveLines = 30; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("big_gap_after_line"); + tag = new TextTag ("big_gap_after_line"); tag.PixelsBelowLines = 30; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("double_spaced_line"); + tag = new TextTag ("double_spaced_line"); tag.PixelsInsideWrap = 10; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("not_editable"); + tag = new TextTag ("not_editable"); tag.Editable = false; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("word_wrap"); + tag = new TextTag ("word_wrap"); tag.WrapMode = WrapMode.Word; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("char_wrap"); + tag = new TextTag ("char_wrap"); tag.WrapMode = WrapMode.Char; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("no_wrap"); + tag = new TextTag ("no_wrap"); tag.WrapMode = WrapMode.None; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("center"); + tag = new TextTag ("center"); tag.Justification = Justification.Center; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("right_justify"); + tag = new TextTag ("right_justify"); tag.Justification = Justification.Right; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("wide_margins"); + tag = new TextTag ("wide_margins"); tag.LeftMargin = 50; tag.RightMargin = 50; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("strikethrough"); + tag = new TextTag ("strikethrough"); tag.Strikethrough = true; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("underline"); + tag = new TextTag ("underline"); tag.Underline = Pango.Underline.Single; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("double_underline"); + tag = new TextTag ("double_underline"); tag.Underline = Pango.Underline.Double; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("superscript"); + tag = new TextTag ("superscript"); tag.Rise = (int) Pango.Scale.PangoScale * 10; tag.Size = (int) Pango.Scale.PangoScale * 8; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("subscript"); + tag = new TextTag ("subscript"); tag.Rise = (int) Pango.Scale.PangoScale * -10; tag.Size = (int) Pango.Scale.PangoScale * 8; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); - tag = new TextTag("rtl_quote"); + tag = new TextTag ("rtl_quote"); tag.WrapMode = WrapMode.Word; tag.Direction = TextDirection.Rtl; tag.Indent = 30; tag.LeftMargin = 20; tag.RightMargin = 20; - buffer.TagTable.Add(tag); + buffer.TagTable.Add (tag); } private void InsertText (TextBuffer buffer) @@ -277,7 +274,7 @@ namespace GtkDemo TextIter insertIter; insertIter = buffer.GetIterAtOffset (0); - buffer.Insert(insertIter, + buffer.Insert (insertIter, "The text widget can display text with all kinds of nifty attributes.It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n"); InsertWithTagsByName (buffer, "Font styles. ", new string[] {"heading"}); @@ -392,29 +389,29 @@ namespace GtkDemo TextIter insertIter, beginIter, endIter; int begin, end; - begin = buffer.CharCount; insertIter = buffer.GetIterAtMark(buffer.InsertMark); buffer.Insert (insertIter, insertText); end = buffer.CharCount; - foreach (string fontItem in fontName){ + foreach (string fontItem in fontName) { endIter = buffer.GetIterAtOffset (end); beginIter = buffer.GetIterAtOffset (begin); - buffer.ApplyTag (fontItem, beginIter, endIter);} + buffer.ApplyTag (fontItem, beginIter, endIter); + } } private void Insert (TextBuffer buffer , string insertText) { TextIter insertIter; - - insertIter = buffer.GetIterAtMark(buffer.InsertMark); + insertIter = buffer.GetIterAtMark (buffer.InsertMark); buffer.Insert (insertIter, insertText); } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } private void RecursiveAttach (int depth, TextView view, TextChildAnchor anchor) @@ -426,7 +423,7 @@ namespace GtkDemo /* Event box is to add a black border around each child view */ EventBox eventBox = new EventBox (); Gdk.Color blackColor = new Gdk.Color (0x0, 0x0, 0x0); - eventBox.ModifyBg(StateType.Normal,blackColor); + eventBox.ModifyBg (StateType.Normal,blackColor); Alignment align = new Alignment (0.5f, 0.5f, 1.0f, 1.0f); align.BorderWidth = 1; @@ -436,8 +433,7 @@ namespace GtkDemo view.AddChildAtAnchor (eventBox, anchor); - RecursiveAttach(depth+1, childView, anchor); - + RecursiveAttach (depth+1, childView, anchor); } private void EasterEggCB (object o, EventArgs args) @@ -445,16 +441,16 @@ namespace GtkDemo TextIter insertIter; TextBuffer bufferCB = new TextBuffer (null); - Insert(bufferCB, "This buffer is shared by a set of nested text views.\n Nested view:\n"); + Insert (bufferCB, "This buffer is shared by a set of nested text views.\n Nested view:\n"); insertIter = bufferCB.GetIterAtMark(bufferCB.InsertMark); TextChildAnchor anchor = bufferCB.CreateChildAnchor (insertIter); - Insert(bufferCB, "\nDon't do this in real applications, please.\n"); + Insert (bufferCB, "\nDon't do this in real applications, please.\n"); TextView viewCB = new TextView (bufferCB); - RecursiveAttach(0, viewCB, anchor); + RecursiveAttach (0, viewCB, anchor); Gtk.Window window = new Gtk.Window (null); - ScrolledWindow scrolledWindow = new ScrolledWindow(null, null); + ScrolledWindow scrolledWindow = new ScrolledWindow (null, null); scrolledWindow.SetPolicy (PolicyType.Automatic, PolicyType.Automatic); window.Add (scrolledWindow); @@ -462,7 +458,6 @@ namespace GtkDemo window.SetDefaultSize (300, 400); window.ShowAll (); - } } } diff --git a/sample/GtkDemo/DemoTreeStore.cs b/sample/GtkDemo/DemoTreeStore.cs index b1f801eac..391debc1c 100644 --- a/sample/GtkDemo/DemoTreeStore.cs +++ b/sample/GtkDemo/DemoTreeStore.cs @@ -22,21 +22,19 @@ using GLib; namespace GtkDemo { - - public class DemoTreeStore + public class DemoTreeStore : Gtk.Window { - private Window window; private TreeStore store; - public DemoTreeStore () + + public DemoTreeStore () : base ("TreeStore Demo") { - window = new Window ("TreeStore Demo"); - window.DeleteEvent += new DeleteEventHandler (WindowDelete); + this.DeleteEvent += new DeleteEventHandler (WindowDelete); VBox vbox = new VBox (false, 8); vbox.BorderWidth = 8; - window.Add (vbox); + this.Add (vbox); - vbox.PackStart(new Label ("Jonathan's Holiday Card Planning Sheet"), false, false, 0); + vbox.PackStart (new Label ("Jonathan's Holiday Card Planning Sheet"), false, false, 0); ScrolledWindow scrolledWindow = new ScrolledWindow (); scrolledWindow.ShadowType = ShadowType.EtchedIn; @@ -44,7 +42,7 @@ namespace GtkDemo vbox.PackStart (scrolledWindow, true, true, 0); // create model - CreateModel(); + CreateModel (); // create tree view TreeView treeView = new TreeView (store); @@ -60,10 +58,8 @@ namespace GtkDemo treeView.ExpandRow (new TreePath (i.ToString ()), false); } - window.SetDefaultSize (650, 400); - - window.ShowAll (); - + this.SetDefaultSize (650, 400); + this.ShowAll (); } private void ItemToggled (object o, ToggledArgs args) @@ -72,11 +68,11 @@ namespace GtkDemo int column = (int) cellRendererToggle.Data["column"]; Gtk.TreeIter iter; - if (store.GetIterFromString(out iter, args.Path)) + if (store.GetIterFromString (out iter, args.Path)) { - bool val = (bool) store.GetValue(iter, column); - Console.WriteLine("toggled {0} with value {1}", args.Path, !val); - store.SetValue(iter, column, !val); + bool val = (bool) store.GetValue (iter, column); + Console.WriteLine ("toggled {0} with value {1}", args.Path, !val); + store.SetValue (iter, column, !val); } } @@ -87,9 +83,9 @@ namespace GtkDemo rendererText.Xalign = 0.0f; GLib.Object ugly = (GLib.Object) rendererText; ugly.Data ["column"] = Column.HolidayName; - TreeViewColumn column = new TreeViewColumn("Holiday", rendererText, + TreeViewColumn column = new TreeViewColumn ("Holiday", rendererText, "text", Column.HolidayName); - treeView.InsertColumn(column, (int) Column.HolidayName); + treeView.InsertColumn (column, (int) Column.HolidayName); // alex column CellRendererToggle rendererToggle = new CellRendererToggle (); @@ -100,12 +96,11 @@ namespace GtkDemo rendererToggle.Visible = true; rendererToggle.Activatable = true; rendererToggle.Active = true; - column = new TreeViewColumn("Alex", rendererToggle, "active", (int) Column.Alex); + column = new TreeViewColumn ("Alex", rendererToggle, "active", (int) Column.Alex); column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 50; column.Clickable = true; - treeView.InsertColumn(column, (int) Column.Alex); - + treeView.InsertColumn (column, (int) Column.Alex); // havoc column rendererToggle = new CellRendererToggle (); @@ -113,11 +108,11 @@ namespace GtkDemo ugly = (GLib.Object) rendererToggle; ugly.Data ["column"] = Column.Havoc; rendererToggle.Toggled += new ToggledHandler (ItemToggled); - column = new TreeViewColumn("Havoc", rendererToggle, "active", (int) Column.Havoc); + column = new TreeViewColumn ("Havoc", rendererToggle, "active", (int) Column.Havoc); column.Visible = true; rendererToggle.Activatable = true; rendererToggle.Active = true; - treeView.InsertColumn(column, (int) Column.Havoc); + treeView.InsertColumn (column, (int) Column.Havoc); column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 50; column.Clickable = true; @@ -128,11 +123,11 @@ namespace GtkDemo ugly = (GLib.Object) rendererToggle; ugly.Data ["column"] = Column.Tim; rendererToggle.Toggled += new ToggledHandler (ItemToggled); - column = new TreeViewColumn("Tim", rendererToggle, "active", (int) Column.Tim); + column = new TreeViewColumn ("Tim", rendererToggle, "active", (int) Column.Tim); column.Visible = true; rendererToggle.Activatable = true; rendererToggle.Active = true; - treeView.InsertColumn(column, (int) Column.Tim); + treeView.InsertColumn (column, (int) Column.Tim); column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 50; column.Clickable = true; @@ -143,11 +138,11 @@ namespace GtkDemo ugly = (GLib.Object) rendererToggle; ugly.Data ["column"] = Column.Owen; rendererToggle.Toggled += new ToggledHandler (ItemToggled); - column = new TreeViewColumn("Owen", rendererToggle, "active", (int) Column.Owen); + column = new TreeViewColumn ("Owen", rendererToggle, "active", (int) Column.Owen); column.Visible = true; rendererToggle.Activatable = true; rendererToggle.Active = true; - treeView.InsertColumn(column, (int) Column.Owen); + treeView.InsertColumn (column, (int) Column.Owen); column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 50; column.Clickable = true; @@ -158,21 +153,21 @@ namespace GtkDemo ugly = (GLib.Object) rendererToggle; ugly.Data ["column"] = Column.Dave; rendererToggle.Toggled += new ToggledHandler (ItemToggled); - column = new TreeViewColumn("Dave", rendererToggle, "active", (int) Column.Dave); + column = new TreeViewColumn ("Dave", rendererToggle, "active", (int) Column.Dave); column.Visible = true; rendererToggle.Activatable = true; rendererToggle.Active = true; - treeView.InsertColumn(column, (int) Column.Dave); + treeView.InsertColumn (column, (int) Column.Dave); column.Sizing = TreeViewColumnSizing.Fixed; column.FixedWidth = 50; column.Clickable = true; - } private void WindowDelete (object o, DeleteEventArgs args) { - window.Hide (); - window.Destroy (); + this.Hide (); + this.Destroy (); + args.RetVal = true; } private void CreateModel () @@ -189,7 +184,6 @@ namespace GtkDemo typeof(bool)); // add data to the tree store - // STUCK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! foreach (MyTreeItem month in toplevel) { @@ -202,21 +196,18 @@ namespace GtkDemo false, false); - foreach (MyTreeItem hollyday in month.Children) - { - store.AppendValues (iter, - hollyday.Label, - hollyday.Alex, - hollyday.Havoc, - hollyday.Tim, - hollyday.Owen, - hollyday.Dave, - true); - - - } + foreach (MyTreeItem hollyday in month.Children) + { + store.AppendValues (iter, + hollyday.Label, + hollyday.Alex, + hollyday.Havoc, + hollyday.Tim, + hollyday.Owen, + hollyday.Dave, + true); + } } - } // tree data @@ -327,7 +318,6 @@ namespace GtkDemo }; // TreeItem structure - // report bug array mismatch declaration public class MyTreeItem { public string Label; diff --git a/sample/GtkDemo/TODO b/sample/GtkDemo/TODO new file mode 100644 index 000000000..aad5dba45 --- /dev/null +++ b/sample/GtkDemo/TODO @@ -0,0 +1,18 @@ +General + - general C#-ification + - embed PixBufs instead of loading from disk + +DemoApplicationWindow + - ItemFactory stuff + +DemoIconFactory + - almost everything + +DemoImages + - fix the progressive loading image + +DemoStockBrowser + - almost everything + +DemoTextView + - small issue with international text