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
This commit is contained in:
John Luke 2004-08-07 17:06:29 +00:00
parent 92553bb827
commit db410e9497
19 changed files with 636 additions and 698 deletions

View file

@ -1,2 +1,4 @@
Makefile Makefile
Makefile.in Makefile.in
GtkDemo.exe
GtkDemo.exe.mdb

View file

@ -19,24 +19,29 @@ using Gtk;
namespace GtkDemo 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, "<Branch>" )}; // static ItemFactoryEntry items[] = { new ItemFactoryEntry ("/_File", null, 0, 0, "<Branch>" )};
public DemoApplicationWindow () public DemoApplicationWindow () : base ("Demo Application Window")
{ {
window = new Gtk.Window ("Demo Application Window"); this.SetDefaultSize (400, 300);
window.SetDefaultSize (400, 300); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
VBox vbox = new VBox (false, 0); VBox vbox = new VBox (false, 0);
window.Add (vbox); this.Add (vbox);
// Create the menubar // Create the menubar
AccelGroup accelGroup = new AccelGroup (); AccelGroup accelGroup = new AccelGroup ();
window.AddAccelGroup (accelGroup); this.AddAccelGroup (accelGroup);
MenuBar menubar = CreateMenu (); MenuBar menubar = CreateMenu ();
vbox.PackStart (menubar, false, false, 0); vbox.PackStart (menubar, false, false, 0);
@ -45,10 +50,12 @@ namespace GtkDemo
vbox.PackStart (toolbar, false, false, 0); vbox.PackStart (toolbar, false, false, 0);
TextView textview = new TextView (); TextView textview = new TextView ();
textview.Buffer.MarkSet += new MarkSetHandler (OnMarkSet);
vbox.PackStart (textview, true, true, 0); vbox.PackStart (textview, true, true, 0);
Statusbar statusbar = new Statusbar (); statusbar = new Statusbar ();
statusbar.Push (1, "Cursor at row 0 column 0 - 0 chars in document"); UpdateStatus ();
vbox.PackStart (statusbar, false, false, 0); vbox.PackStart (statusbar, false, false, 0);
//ItemFactory itemFactory = new ItemFactory (typeof (MenuBar),"<main>", accelGroup); //ItemFactory itemFactory = new ItemFactory (typeof (MenuBar),"<main>", accelGroup);
@ -63,7 +70,7 @@ namespace GtkDemo
// create menu items // create menu items
//STUCK : Didn't find any examples of ItemFactory //STUCK : Didn't find any examples of ItemFactory
window.ShowAll (); this.ShowAll ();
} }
private MenuBar CreateMenu () private MenuBar CreateMenu ()
@ -95,16 +102,32 @@ namespace GtkDemo
private void OnToolbarClicked (object o, EventArgs args) private void OnToolbarClicked (object o, EventArgs args)
{ {
MessageDialog md = new MessageDialog (window, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "You selected a toolbar button."); using (MessageDialog md = new MessageDialog (this, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "You selected a toolbar button.")) {
md.Run (); md.Run ();
md.Hide (); md.Hide ();
md.Dispose (); }
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); 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));
} }
} }
} }

View file

@ -12,25 +12,20 @@
*/ */
using System; using System;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoButtonBox public class DemoButtonBox : Gtk.Window
{ {
private Gtk.Window window; public DemoButtonBox () : base ("Button Boxes")
public DemoButtonBox ()
{ {
// Create a Window this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window = new Gtk.Window ("Button Boxes"); this.BorderWidth = 10;
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.BorderWidth = 10;
// Add Vertical Box // Add Vertical Box
VBox mainVbox = new VBox (false,0); VBox mainVbox = new VBox (false,0);
window.Add (mainVbox); this.Add (mainVbox);
// Add Horizontal Frame // Add Horizontal Frame
Frame horizontalFrame = new Frame ("Horizontal Button Boxes"); 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, "Start (spacing 20)", 20, 85, 20, ButtonBoxStyle.Start));
hbox.PackStart(CreateButtonBox (false, "End (spacing 20)", 20, 85, 20, ButtonBoxStyle.End)); hbox.PackStart(CreateButtonBox (false, "End (spacing 20)", 20, 85, 20, ButtonBoxStyle.End));
window.ShowAll (); this.ShowAll ();
} }
// Create a Button Box with the specified parameters // Create a Button Box with the specified parameters
@ -95,8 +90,9 @@ namespace GtkDemo
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
} }
} }

View file

@ -13,28 +13,23 @@
*/ */
using System; using System;
using Gdk; using Gdk;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoColorSelection public class DemoColorSelection : Gtk.Window
{ {
private Gtk.Window window ;
private Gdk.Color color; private Gdk.Color color;
private ColorSelectionDialog colorSelectionDialog;
private Gtk.DrawingArea drawingArea; private Gtk.DrawingArea drawingArea;
public DemoColorSelection () public DemoColorSelection () : base ("Color Selection")
{ {
window = new Gtk.Window ("Color Selection"); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete); this.BorderWidth = 8;
window.BorderWidth = 8;
VBox vbox = new VBox (false,8); VBox vbox = new VBox (false,8);
vbox.BorderWidth = 8; vbox.BorderWidth = 8;
window.Add (vbox); this.Add (vbox);
// Create the color swatch area // Create the color swatch area
Frame frame = new Frame (); Frame frame = new Frame ();
@ -56,13 +51,14 @@ namespace GtkDemo
alignment.Add (button); alignment.Add (button);
vbox.PackStart (alignment); vbox.PackStart (alignment);
window.ShowAll (); this.ShowAll ();
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
// Expose callback for the drawing area // Expose callback for the drawing area
@ -72,7 +68,7 @@ namespace GtkDemo
Gdk.Window window = eventExpose.Window; Gdk.Window window = eventExpose.Window;
Rectangle area = eventExpose.Area; Rectangle area = eventExpose.Area;
window.DrawRectangle (drawingArea.Style.BackgroundGC(StateType.Normal), window.DrawRectangle (drawingArea.Style.BackgroundGC (StateType.Normal),
true, true,
area.X, area.Y, area.X, area.Y,
area.Width, area.Height); area.Width, area.Height);
@ -81,28 +77,21 @@ namespace GtkDemo
private void ChangeColorCallback (object o, EventArgs args) private void ChangeColorCallback (object o, EventArgs args)
{ {
colorSelectionDialog = new ColorSelectionDialog ("Changing color"); using (ColorSelectionDialog colorSelectionDialog = new ColorSelectionDialog ("Changing color")) {
colorSelectionDialog.TransientFor = window; colorSelectionDialog.TransientFor = this;
colorSelectionDialog.ColorSelection.PreviousColor = color; colorSelectionDialog.ColorSelection.PreviousColor = color;
colorSelectionDialog.ColorSelection.CurrentColor = color; colorSelectionDialog.ColorSelection.CurrentColor = color;
colorSelectionDialog.ColorSelection.HasPalette = true; colorSelectionDialog.ColorSelection.HasPalette = true;
colorSelectionDialog.CancelButton.Clicked += new EventHandler (Color_Selection_Cancel); if (colorSelectionDialog.Run () == (int) ResponseType.Ok)
colorSelectionDialog.OkButton.Clicked += new EventHandler (Color_Selection_OK);
colorSelectionDialog.ShowAll();
}
private void Color_Selection_OK (object o, EventArgs args)
{ {
Gdk.Color selected = colorSelectionDialog.ColorSelection.CurrentColor; Gdk.Color selected = colorSelectionDialog.ColorSelection.CurrentColor;
drawingArea.ModifyBg (StateType.Normal, selected); drawingArea.ModifyBg (StateType.Normal, selected);
colorSelectionDialog.Destroy ();
} }
private void Color_Selection_Cancel (object o, EventArgs args) colorSelectionDialog.Hide ();
{ }
colorSelectionDialog.Destroy ();
} }
} }
} }

View file

@ -16,26 +16,24 @@
// - Check how to handle response type. Can we make the button to have // - Check how to handle response type. Can we make the button to have
// the binding to the cancel signal automagicly like in // the binding to the cancel signal automagicly like in
// gtk_dialog_new_with_buttons or should we just use the if ? // gtk_dialog_new_with_buttons or should we just use the if ?
using System;
using System;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoDialog public class DemoDialog : Gtk.Window
{ {
private Gtk.Window window;
private Entry entry1; private Entry entry1;
private Entry entry2; private Entry entry2;
public DemoDialog () public DemoDialog () : base ("Dialogs")
{ {
window = new Gtk.Window ("Dialogs"); this.DeleteEvent += new DeleteEventHandler(WindowDelete);
window.DeleteEvent += new DeleteEventHandler(WindowDelete); this.BorderWidth = 8;
window.BorderWidth = 8;
Frame frame = new Frame ("Dialogs"); Frame frame = new Frame ("Dialogs");
window.Add (frame); this.Add (frame);
VBox vbox = new VBox (false, 8); VBox vbox = new VBox (false, 8);
vbox.BorderWidth = 8; vbox.BorderWidth = 8;
@ -76,36 +74,40 @@ namespace GtkDemo
table.Attach (entry2, 1, 2, 1, 2); table.Attach (entry2, 1, 2, 1, 2);
label.MnemonicWidget = entry2; label.MnemonicWidget = entry2;
window.ShowAll (); this.ShowAll ();
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
private int i = 1; private int i = 1;
private void MessageDialogClicked (object o, EventArgs args) 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); 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,
using (Dialog dialog = new MessageDialog (this,
DialogFlags.Modal | DialogFlags.DestroyWithParent, DialogFlags.Modal | DialogFlags.DestroyWithParent,
MessageType.Info, MessageType.Info,
ButtonsType.Ok, ButtonsType.Ok,
message); message)) {
dialog.Run (); dialog.Run ();
dialog.Destroy (); dialog.Hide ();
}
i++; i++;
} }
private void InteractiveDialogClicked (object o, EventArgs args) private void InteractiveDialogClicked (object o, EventArgs args)
{ {
MessageDialog dialog = new MessageDialog (window, using (MessageDialog dialog = new MessageDialog (this,
DialogFlags.Modal | DialogFlags.DestroyWithParent, DialogFlags.Modal | DialogFlags.DestroyWithParent,
MessageType.Question, MessageType.Question,
ButtonsType.Ok, ButtonsType.Ok,
null); null)) {
dialog.AddButton ("_Non-stock Button", (int) ResponseType.Cancel); dialog.AddButton ("_Non-stock Button", (int) ResponseType.Cancel);
@ -142,7 +144,9 @@ namespace GtkDemo
entry2.Text = localEntry2.Text; entry2.Text = localEntry2.Text;
} }
dialog.Destroy (); dialog.Hide ();
}
} }
} }
} }

View file

@ -22,32 +22,29 @@
* to clear the area. * to clear the area.
*/ */
using System; using System;
using Gtk; using Gtk;
using Gdk; using Gdk;
namespace GtkDemo { namespace GtkDemo
public class DemoDrawingArea {
public class DemoDrawingArea : Gtk.Window
{ {
private Gtk.Window window;
private static Pixmap pixmap = null; private static Pixmap pixmap = null;
private static DrawingArea drawingArea; private static DrawingArea drawingArea;
private static DrawingArea drawingArea1; private static DrawingArea drawingArea1;
public DemoDrawingArea () public DemoDrawingArea () : base ("Drawing Area")
{ {
window = new Gtk.Window ("Drawing Area"); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete); this.BorderWidth = 8;
window.BorderWidth = 8;
VBox vbox = new VBox (false, 8); VBox vbox = new VBox (false, 8);
vbox.BorderWidth = 8; vbox.BorderWidth = 8;
window.Add (vbox); this.Add (vbox);
// Create the checkerboard area // Create the checkerboard area
Label label = new Label(null); Label label = new Label ();
label.Markup = "<u>Checkerboard pattern</u>"; label.Markup = "<u>Checkerboard pattern</u>";
vbox.PackStart (label, false, false, 0); vbox.PackStart (label, false, false, 0);
@ -55,10 +52,10 @@ namespace GtkDemo {
frame.ShadowType = ShadowType.In; frame.ShadowType = ShadowType.In;
vbox.PackStart (frame, true, true, 0); vbox.PackStart (frame, true, true, 0);
drawingArea = new DrawingArea(); drawingArea = new DrawingArea ();
// set a minimum size // set a minimum size
drawingArea.SetSizeRequest (100,100); drawingArea.SetSizeRequest (100,100);
frame.Add(drawingArea); frame.Add (drawingArea);
drawingArea.ExposeEvent += new ExposeEventHandler (CheckerboardExpose); drawingArea.ExposeEvent += new ExposeEventHandler (CheckerboardExpose);
// Create the scribble area // Create the scribble area
@ -87,13 +84,14 @@ namespace GtkDemo {
drawingArea1.Events = EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | drawingArea1.Events = EventMask.LeaveNotifyMask | EventMask.ButtonPressMask |
EventMask.PointerMotionMask | EventMask.PointerMotionHintMask; EventMask.PointerMotionMask | EventMask.PointerMotionHintMask;
window.ShowAll (); this.ShowAll ();
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
private void CheckerboardExpose (object o, ExposeEventArgs args) private void CheckerboardExpose (object o, ExposeEventArgs args)
@ -122,7 +120,6 @@ namespace GtkDemo {
color.Blue = 65535; color.Blue = 65535;
gc2.RgbFgColor = color; gc2.RgbFgColor = color;
// Start redrawing the Checkerboard // Start redrawing the Checkerboard
xcount = 0; xcount = 0;
i = Spacing; i = Spacing;
@ -146,7 +143,6 @@ namespace GtkDemo {
// return true because we've handled this event, so no // return true because we've handled this event, so no
// further processing is required. // further processing is required.
args.RetVal = true; args.RetVal = true;
} }
private void ScribbleExpose (object o, ExposeEventArgs args) private void ScribbleExpose (object o, ExposeEventArgs args)
@ -218,7 +214,6 @@ namespace GtkDemo {
args.RetVal = true; args.RetVal = true;
} }
// Draw a rectangle on the screen // Draw a rectangle on the screen
static void DrawBrush (double x, double y) static void DrawBrush (double x, double y)
{ {

View file

@ -16,26 +16,23 @@
using System; using System;
using System.Collections; using System.Collections;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoEditableCells public class DemoEditableCells : Gtk.Window
{ {
private Gtk.Window window;
private ListStore store; private ListStore store;
private TreeView treeView; private TreeView treeView;
private ArrayList articles; private ArrayList articles;
public DemoEditableCells () public DemoEditableCells () : base ("Color Selection")
{ {
window = new Gtk.Window ("Color Selection"); this.SetDefaultSize (320, 200);
window.SetDefaultSize (320, 200); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
VBox vbox = new VBox (false, 5); 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); 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); button.Clicked += new EventHandler (RemoveItem);
hbox.PackStart (button, true, true, 0); hbox.PackStart (button, true, true, 0);
window.ShowAll (); this.ShowAll ();
} }
private void AddColumns () private void AddColumns ()
{ {
CellRendererText renderer; CellRendererText renderer;
@ -79,7 +74,6 @@ namespace GtkDemo
treeView.AppendColumn ("Number", renderer, treeView.AppendColumn ("Number", renderer,
"text", (int) Column.Number); "text", (int) Column.Number);
// product column // product column
renderer = new CellRendererText (); renderer = new CellRendererText ();
renderer.Edited += new EditedHandler (TextCellEdited); renderer.Edited += new EditedHandler (TextCellEdited);
@ -91,7 +85,6 @@ namespace GtkDemo
private void CreateModel () private void CreateModel ()
{ {
// create array // create array
articles = new ArrayList (); articles = new ArrayList ();
AddItems (); AddItems ();
@ -101,7 +94,6 @@ namespace GtkDemo
// add items // add items
foreach (Item item in articles) foreach (Item item in articles)
store.AppendValues (item.Number, item.Product, item.Editable); store.AppendValues (item.Number, item.Product, item.Editable);
} }
private void AddItems () private void AddItems ()
@ -126,58 +118,42 @@ namespace GtkDemo
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); 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) private void NumberCellEdited (object o, EditedArgs args)
{ {
int i; int i;
Item foo;
try try
{ {
i = Convert.ToInt32(args.Path); i = Convert.ToInt32 (args.Path);
foo = (Item) articles[i];
foo.Number = int.Parse (args.NewText);
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine ("Exeception {0}",e); Console.WriteLine (e.ToString ());
return; // This return should exit the callback but it doesn't return;
} }
Console.WriteLine ("--NUMBER--1");
// //Console.WriteLine ("Path {0}", args.Path); TreeIter iter;
// //Console.WriteLine ("NewText {0}", args.NewText); store.GetIterFromString (out iter, args.Path);
// //Console.WriteLine ("articles[i] {0}",articles[i]); store.SetValue (iter, (int) Column.Number, foo.Number);
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);
} }
private void TextCellEdited (object o, EditedArgs args) private void TextCellEdited (object o, EditedArgs args)
{ {
int i = Convert.ToInt32(args.Path); int i = int.Parse (args.Path);
// Console.WriteLine ("--PRODUCT--");
// Console.WriteLine ("Path {0}", args.Path);
// Console.WriteLine ("NewText {0}", args.NewText);
// Console.WriteLine ("articles[i] {0}",articles[i]);
Item foo = (Item) articles[i]; Item foo = (Item) articles[i];
// Console.WriteLine ("foo.Product {0}", foo.Product);
// Console.WriteLine ("");
foo.Product = args.NewText; foo.Product = args.NewText;
TreeIter iter = new TreeIter (); TreeIter iter;
store.GetIterFromString(out iter, args.Path); store.GetIterFromString (out iter, args.Path);
store.SetValue(iter, (int) Column.Product, foo.Product); store.SetValue (iter, (int) Column.Product, foo.Product);
} }
private void AddItem (object o, EventArgs args) private void AddItem (object o, EventArgs args)
@ -194,10 +170,9 @@ namespace GtkDemo
if (treeView.Selection.GetSelected (out model, out iter)) 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); store.Remove (ref iter);
//articles.RemoveAt (path.Indices[0]); articles.RemoveAt (position);
} }
} }
} }
@ -229,7 +204,7 @@ namespace GtkDemo
private string ProductItem; private string ProductItem;
private bool EditableItem; private bool EditableItem;
public Item (int number , string product, bool editable) public Item (int number, string product, bool editable)
{ {
NumberItem = number; NumberItem = number;
ProductItem = product; ProductItem = product;

View file

@ -31,21 +31,21 @@ using System.IO;
using Gtk; using Gtk;
using Gdk; using Gdk;
namespace GtkDemo { namespace GtkDemo
public class DemoImages {
public class DemoImages : Gtk.Window
{ {
private Gtk.Window window;
private static Gtk.Image progressiveImage; private static Gtk.Image progressiveImage;
private VBox vbox; private VBox vbox;
public DemoImages ()
public DemoImages () : base ("images")
{ {
window = new Gtk.Window ("Images"); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete); this.BorderWidth = 8;
window.BorderWidth = 8;
vbox = new VBox (false, 8); vbox = new VBox (false, 8);
vbox.BorderWidth = 8; vbox.BorderWidth = 8;
window.Add (vbox); this.Add (vbox);
Gtk.Label label = new Gtk.Label ("<u>Image loaded from a file</u>"); Gtk.Label label = new Gtk.Label ("<u>Image loaded from a file</u>");
label.UseMarkup = true; label.UseMarkup = true;
@ -104,13 +104,14 @@ namespace GtkDemo {
vbox.PackStart (button, false, false, 0); vbox.PackStart (button, false, false, 0);
button.Toggled += new EventHandler (ToggleSensitivity); button.Toggled += new EventHandler (ToggleSensitivity);
window.ShowAll (); this.ShowAll ();
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
private void ToggleSensitivity (object o, EventArgs args) private void ToggleSensitivity (object o, EventArgs args)
@ -122,7 +123,6 @@ namespace GtkDemo {
widget.Sensitive = !widget.Sensitive; widget.Sensitive = !widget.Sensitive;
} }
private uint timeout_id; private uint timeout_id;
private void StartProgressiveLoading () private void StartProgressiveLoading ()
{ {
@ -160,6 +160,5 @@ namespace GtkDemo {
{ {
} }
} }
} }

View file

@ -21,24 +21,22 @@ using Gdk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoItemFactory public class DemoItemFactory : Gtk.Window
{ {
private Gtk.Window window; public DemoItemFactory () : base ("Demo Item Factory")
public DemoItemFactory ()
{ {
window = new Gtk.Window (null); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
Gtk.AccelGroup accelGroup = new Gtk.AccelGroup (); Gtk.AccelGroup accelGroup = new Gtk.AccelGroup ();
//STUCK OUCH !!!! //STUCK OUCH !!!!
window.ShowAll (); this.ShowAll ();
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
} }
} }

View file

@ -21,27 +21,26 @@ using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoListStore : Gtk.Window
public class DemoListStore
{ {
private Window window;
ListStore store; ListStore store;
public DemoListStore (){
window = new Window ("ListStore Demo"); public DemoListStore () : base ("ListStore Demo")
window.DeleteEvent += new DeleteEventHandler (WindowDelete); {
this.DeleteEvent += new DeleteEventHandler (WindowDelete);
VBox vbox = new VBox (false, 8); VBox vbox = new VBox (false, 8);
vbox.BorderWidth = 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 scrolledWindow = new ScrolledWindow ();
scrolledWindow.ShadowType = ShadowType.EtchedIn; scrolledWindow.ShadowType = ShadowType.EtchedIn;
scrolledWindow.SetPolicy (PolicyType.Automatic, PolicyType.Automatic); scrolledWindow.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
vbox.PackStart (scrolledWindow, true, true, 0); vbox.PackStart (scrolledWindow, true, true, 0);
// create model // create model
CreateModel(); CreateModel ();
// create tree view // create tree view
TreeView treeView = new TreeView (store); TreeView treeView = new TreeView (store);
@ -51,21 +50,18 @@ namespace GtkDemo
scrolledWindow.Add (treeView); scrolledWindow.Add (treeView);
// finish & show // finish & show
window.SetDefaultSize (650, 400); this.SetDefaultSize (650, 400);
window.ShowAll (); this.ShowAll ();
} }
//FIXME: Finish implementing this function, I don't know
// why it doesn't work.
private void ItemToggled (object o, ToggledArgs args) private void ItemToggled (object o, ToggledArgs args)
{ {
Gtk.TreeIter iter; Gtk.TreeIter iter;
if (store.GetIterFromString(out iter, args.Path)) if (store.GetIterFromString (out iter, args.Path))
{ {
bool val = (bool) store.GetValue(iter, 0); bool val = (bool) store.GetValue (iter, 0);
Console.WriteLine("toggled {0} with value {1}", args.Path, val); Console.WriteLine ("toggled {0} with value {1}", args.Path, val);
store.SetValue(iter, 0, !val); store.SetValue (iter, 0, !val);
} }
} }
@ -74,37 +70,36 @@ namespace GtkDemo
// column for fixed toggles // column for fixed toggles
CellRendererToggle rendererToggle = new CellRendererToggle (); CellRendererToggle rendererToggle = new CellRendererToggle ();
rendererToggle.Toggled += new ToggledHandler (ItemToggled); 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.Active = true;
rendererToggle.Activatable = true; rendererToggle.Activatable = true;
rendererToggle.Visible = true; rendererToggle.Visible = true;
// set this column to a fixed sizing (of 50 pixels) // set this column to a fixed sizing (of 50 pixels)
column.Sizing = TreeViewColumnSizing.Fixed; column.Sizing = TreeViewColumnSizing.Fixed;
column.FixedWidth = 50; column.FixedWidth = 50;
treeView.AppendColumn(column); treeView.AppendColumn (column);
// column for bug numbers // column for bug numbers
CellRendererText rendererText = new CellRendererText (); 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; column.SortColumnId = (int) ColumnNumber.Number;
treeView.AppendColumn(column); treeView.AppendColumn (column);
// column for severities // column for severities
rendererText = new CellRendererText (); rendererText = new CellRendererText ();
column = new TreeViewColumn("Severity", rendererText, "text", ColumnNumber.Severity); column = new TreeViewColumn ("Severity", rendererText, "text", ColumnNumber.Severity);
column.SortColumnId = (int) ColumnNumber.Severity; column.SortColumnId = (int) ColumnNumber.Severity;
treeView.AppendColumn(column); treeView.AppendColumn(column);
// column for description // column for description
rendererText = new CellRendererText (); rendererText = new CellRendererText ();
column = new TreeViewColumn("Description", rendererText, "text", ColumnNumber.Description); column = new TreeViewColumn ("Description", rendererText, "text", ColumnNumber.Description);
column.SortColumnId = (int) ColumnNumber.Description; column.SortColumnId = (int) ColumnNumber.Description;
treeView.AppendColumn(column); treeView.AppendColumn (column);
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
private void CreateModel () private void CreateModel ()
@ -119,11 +114,13 @@ namespace GtkDemo
store.AppendValues(bug.Fixed, store.AppendValues(bug.Fixed,
bug.Number, bug.Number,
bug.Severity, 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 public enum ColumnNumber
{ {
Fixed, Fixed,
@ -132,8 +129,6 @@ namespace GtkDemo
Description, Description,
} }
private static Bug[] bugs = private static Bug[] bugs =
{ {
new Bug ( false, 60482, "Normal", "scrollable notebooks and hidden tabs"), new Bug ( false, 60482, "Normal", "scrollable notebooks and hidden tabs"),
@ -153,7 +148,6 @@ namespace GtkDemo
}; };
} }
public class Bug public class Bug
{ {
public bool Fixed; public bool Fixed;
@ -161,9 +155,7 @@ namespace GtkDemo
public string Severity; public string Severity;
public string Description; public string Description;
public Bug ( bool status, public Bug (bool status, int number, string severity,
int number,
string severity,
string description) string description)
{ {
Fixed = status; Fixed = status;
@ -172,5 +164,4 @@ namespace GtkDemo
Description = description; Description = description;
} }
} }
} }

View file

@ -18,8 +18,8 @@ namespace GtkDemo
public class DemoMain public class DemoMain
{ {
private Gtk.Window window; private Gtk.Window window;
private TextBuffer infoBuffer = new TextBuffer(null); private TextBuffer infoBuffer = new TextBuffer (null);
private TextBuffer sourceBuffer = new TextBuffer(null); private TextBuffer sourceBuffer = new TextBuffer (null);
private TreeView treeView; private TreeView treeView;
private TreeStore store; private TreeStore store;
public static void Main (string[] args) public static void Main (string[] args)
@ -55,22 +55,21 @@ namespace GtkDemo
window.ShowAll (); window.ShowAll ();
} }
private void LoadFile(string filename) private void LoadFile (string filename)
{ {
Stream file = File.OpenRead (filename);
Stream file = File.OpenRead(filename); StreamReader sr = new StreamReader (file);
StreamReader sr = new StreamReader(file); string s = sr.ReadToEnd ();
string s = sr.ReadToEnd(); sr.Close ();
sr.Close(); file.Close ();
file.Close();
infoBuffer.Text = filename; infoBuffer.Text = filename;
sourceBuffer.Text = s; 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 // The gtk-logo-rgb icon has a white background, make it transparent
Pixbuf transparent = pixbuf.AddAlpha (true, 0xff, 0xff, 0xff); Pixbuf transparent = pixbuf.AddAlpha (true, 0xff, 0xff, 0xff);
Gdk.Pixbuf[] list = new Gdk.Pixbuf [1]; Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {transparent};
list[0] = transparent;
Gtk.Window.DefaultIconList = list;
} }
} }
@ -119,7 +115,6 @@ namespace GtkDemo
FontDescription fontDescription = FontDescription.FromString ("Courier 12"); FontDescription fontDescription = FontDescription.FromString ("Courier 12");
textView.ModifyFont (fontDescription); textView.ModifyFont (fontDescription);
textView.WrapMode = Gtk.WrapMode.None; textView.WrapMode = Gtk.WrapMode.None;
} }
else else
{ {
@ -132,7 +127,6 @@ namespace GtkDemo
return scrolledWindow; return scrolledWindow;
} }
private TreeView CreateTree () private TreeView CreateTree ()
{ {
treeView = new TreeView (); treeView = new TreeView ();
@ -143,7 +137,7 @@ namespace GtkDemo
{ {
store = new TreeStore (typeof (string)); store = new TreeStore (typeof (string));
store.AppendValues ("Application Window (5% complete)"); store.AppendValues ("Application Window (75% complete)");
store.AppendValues ("Button Boxes"); store.AppendValues ("Button Boxes");
store.AppendValues ("Change Display"); store.AppendValues ("Change Display");
store.AppendValues ("Color Selector"); store.AppendValues ("Color Selector");
@ -158,16 +152,15 @@ namespace GtkDemo
store.AppendValues ("Stock Item and Icon Browser (10% complete)"); store.AppendValues ("Stock Item and Icon Browser (10% complete)");
store.AppendValues ("Text Widget (95% complete)"); store.AppendValues ("Text Widget (95% complete)");
TreeIter iter = store.AppendValues ("Tree View"); 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, "List Store");
store.AppendValues (iter, "Tree Store (95% complete)"); store.AppendValues (iter, "Tree Store");
return store; return store;
} }
private void OnTreeChanged (object o, EventArgs args) private void OnTreeChanged (object o, EventArgs args)
{ {
TreeIter iter; TreeIter iter;
TreeModel model; TreeModel model;
@ -235,7 +228,6 @@ namespace GtkDemo
default: default:
break; break;
} }
} }
} }

View file

@ -41,25 +41,21 @@
// point on the right side // point on the right side
using System; using System;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoMenus public class DemoMenus : Gtk.Window
{ {
private Gtk.Window window; public DemoMenus () : base ("Menus")
public DemoMenus ()
{ {
window = new Window ("Menus"); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
AccelGroup accel_group = new AccelGroup (); AccelGroup accel_group = new AccelGroup ();
window.AddAccelGroup (accel_group); this.AddAccelGroup (accel_group);
VBox box1 = new VBox (false, 0); VBox box1 = new VBox (false, 0);
window.Add (box1); this.Add (box1);
MenuBar menubar = new MenuBar (); MenuBar menubar = new MenuBar ();
box1.PackStart (menubar, false, false, 0); box1.PackStart (menubar, false, false, 0);
@ -128,7 +124,7 @@ namespace GtkDemo
close_button.CanDefault = true; close_button.CanDefault = true;
close_button.GrabDefault (); close_button.GrabDefault ();
window.ShowAll (); this.ShowAll ();
} }
private Menu Create_Menu (int depth, bool tearoff) private Menu Create_Menu (int depth, bool tearoff)
@ -170,14 +166,15 @@ namespace GtkDemo
private void Close_Button (object o, EventArgs args) private void Close_Button (object o, EventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
} }
} }

View file

@ -22,14 +22,12 @@
using System; using System;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoPanes public class DemoPanes : Gtk.Window
{ {
private Window window;
private VPaned vpaned; private VPaned vpaned;
private HPaned top; private HPaned top;
private Frame left; private Frame left;
@ -45,14 +43,14 @@ namespace GtkDemo
private CheckButton resizeBottom; private CheckButton resizeBottom;
private CheckButton shrinkBottom; private CheckButton shrinkBottom;
private Button button; private Button button;
public DemoPanes ()
public DemoPanes () : base ("Panes")
{ {
window = new Window ("Panes"); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete); this.BorderWidth = 0;
window.BorderWidth = 0;
VBox vbox = new VBox (false, 0); VBox vbox = new VBox (false, 0);
window.Add (vbox); this.Add (vbox);
vpaned = new VPaned (); vpaned = new VPaned ();
vbox.PackStart (vpaned, true, true, 0); vbox.PackStart (vpaned, true, true, 0);
@ -144,39 +142,37 @@ namespace GtkDemo
shrinkBottom.Active = true; shrinkBottom.Active = true;
shrinkBottom.Toggled += new EventHandler (BottomCB); 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.Remove (left);
top.Pack1(left, resizeLeft.Active, shrinkLeft.Active); 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.Remove (right);
top.Pack2(right, resizeRight.Active, shrinkRight.Active); 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.Remove (top);
vpaned.Pack1(top, resizeTop.Active, shrinkTop.Active); 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.Remove (bottom);
vpaned.Pack2(bottom, resizeBottom.Active, shrinkBottom.Active); vpaned.Pack2 (bottom, resizeBottom.Active, shrinkBottom.Active);
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
} }
} }
} }

View file

@ -29,11 +29,11 @@ namespace GtkDemo
{ {
public class DemoPixbuf : Gtk.Window public class DemoPixbuf : Gtk.Window
{ {
const int FrameDelay = 50; const int FrameDelay = 50;
const int CycleLen = 60; const int CycleLen = 60;
const string BackgroundName = "images/background.jpg"; const string BackgroundName = "images/background.jpg";
string [] ImageNames = { string [] ImageNames = {
"images/apple-red.png", "images/apple-red.png",
"images/gnome-applets.png", "images/gnome-applets.png",
@ -59,9 +59,6 @@ namespace GtkDemo
// drawing area // drawing area
DrawingArea drawingArea; DrawingArea drawingArea;
string FindFile (string name) string FindFile (string name)
{ {
return name; return name;
@ -81,11 +78,9 @@ namespace GtkDemo
images[i] = new Pixbuf (FindFile (ImageNames[i])); images[i] = new Pixbuf (FindFile (ImageNames[i]));
} }
// Expose callback for the drawing area // Expose callback for the drawing area
void Expose (object o, ExposeEventArgs args) void Expose (object o, ExposeEventArgs args)
{ {
EventExpose ev = args.Event; EventExpose ev = args.Event;
Widget widget = (Widget) o; Widget widget = (Widget) o;
Gdk.Rectangle area = ev.Area; Gdk.Rectangle area = ev.Area;
@ -98,11 +93,8 @@ namespace GtkDemo
Gdk.PixbufAlphaMode.Full, 8, Gdk.PixbufAlphaMode.Full, 8,
RgbDither.Normal, RgbDither.Normal,
100, 100); 100, 100);
} }
// timeout handler to regenerate the frame // timeout handler to regenerate the frame
bool timeout () bool timeout ()
{ {
@ -140,7 +132,7 @@ namespace GtkDemo
r1 = new Rectangle (xpos, ypos,(int) (iw * k), r1 = new Rectangle (xpos, ypos,(int) (iw * k),
(int) (ih * 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);
@ -154,7 +146,7 @@ namespace GtkDemo
2 * Math.PI))) 2 * Math.PI)))
: Math.Max (127, Math.Abs (255 * Math.Cos (f * : Math.Max (127, Math.Abs (255 * Math.Cos (f *
2 * Math.PI))))); 2 * Math.PI)))));
*/ */
images[i].Composite (frame, r1.X, r1.Y, r1.Width, images[i].Composite (frame, r1.X, r1.Y, r1.Width,
r1.Height, xpos, ypos, k, k, r1.Height, xpos, ypos, k, k,
InterpType.Nearest, (int) ((i % 2 == 1) InterpType.Nearest, (int) ((i % 2 == 1)
@ -170,23 +162,23 @@ namespace GtkDemo
return true; return true;
} }
private Gtk.Window window;
public DemoPixbuf () : base ("Gdk Pixbuf Demo") public DemoPixbuf () : base ("Gdk Pixbuf Demo")
{ {
//window = new DemoPixbuf (); this.DeleteEvent += new DeleteEventHandler (OnWindowDelete);
//window.DeleteEvent += new DeleteEventHandler (WindowDelete);
try { try
{
LoadPixbuf (); LoadPixbuf ();
} catch (Exception e) { } catch (Exception e)
MessageDialog md = new MessageDialog (this, {
using (MessageDialog md = new MessageDialog (this,
DialogFlags.DestroyWithParent, DialogFlags.DestroyWithParent,
MessageType.Error, MessageType.Error,
ButtonsType.Close, ButtonsType.Close,
"Error: \n" + e.Message); "Error: \n" + e.Message)) {
md.Run (); md.Run ();
md.Hide ();
}
throw; throw;
} }
@ -201,17 +193,16 @@ namespace GtkDemo
GLib.Timeout.Add (FrameDelay, new GLib.TimeoutHandler(timeout)); GLib.Timeout.Add (FrameDelay, new GLib.TimeoutHandler(timeout));
this.SetDefaultSize (backWidth, backHeight); this.SetDefaultSize (backWidth, backHeight);
// this.Resizable = false; // this.Resizable = false;
ShowAll (); ShowAll ();
} }
void OnWindowDelete (object obj, DeleteEventArgs args)
static void windowDelete (object obj, DeleteEventArgs args)
{ {
Application.Quit (); this.Hide ();
this.Destroy ();
args.RetVal = true;
}
} }
}
} }

View file

@ -22,24 +22,21 @@
*/ */
using System; using System;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoSizeGroup public class DemoSizeGroup : Dialog
{ {
private Dialog window;
private SizeGroup sizeGroup; private SizeGroup sizeGroup;
public DemoSizeGroup () public DemoSizeGroup ()
{ {
window = new Dialog (); this.Title = "Size groups";
window.Title = "Sized groups"; this.Resizable = false;
window.Resizable = false;
VBox vbox = new VBox (false, 5); VBox vbox = new VBox (false, 5);
window.VBox.PackStart (vbox, true, true, 0); this.VBox.PackStart (vbox, true, true, 0);
vbox.BorderWidth = 5; vbox.BorderWidth = 5;
sizeGroup = new SizeGroup (SizeGroupMode.Horizontal); sizeGroup = new SizeGroup (SizeGroupMode.Horizontal);
@ -81,10 +78,10 @@ namespace GtkDemo
checkButton.Toggled += new EventHandler (ButtonToggleCb); checkButton.Toggled += new EventHandler (ButtonToggleCb);
Button CloseButton = new Button (Stock.Close); Button CloseButton = new Button (Stock.Close);
window.AddActionWidget (CloseButton, 5); this.AddActionWidget (CloseButton, ResponseType.Close);
window.Response += new ResponseHandler (ResponseCallback); this.Response += new ResponseHandler (ResponseCallback);
window.ShowAll (); this.ShowAll ();
} }
// Convenience function to create an option menu holding a number of strings // 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) private void ResponseCallback (object obj, ResponseArgs args)
{ {
if (((int) args.ResponseId) == 5) { if ((args.ResponseId) == ResponseType.Close) {
window.Hide (); this.Hide ();
window.Destroy ();} this.Destroy ();
}
} }
} }
} }

View file

@ -6,24 +6,20 @@
// (C) 2003 Ximian, Inc. // (C) 2003 Ximian, Inc.
using System; using System;
using Gtk; using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoStockBrowser public class DemoStockBrowser : Gtk.Window
{ {
private Gtk.Window window; public DemoStockBrowser () : base ("Stock Item Browser Demo")
public DemoStockBrowser ()
{ {
window = new Gtk.Window ("Stock Item Browser Demo"); this.SetDefaultSize (600, 400);
window.SetDefaultSize (600, 400); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete); this.BorderWidth = 8;
window.BorderWidth = 8;
HBox hbox = new HBox (false, 8); HBox hbox = new HBox (false, 8);
window.Add (hbox); this.Add (hbox);
ScrolledWindow scrolledWindow = new ScrolledWindow (null, null); ScrolledWindow scrolledWindow = new ScrolledWindow (null, null);
scrolledWindow.SetPolicy (PolicyType.Never, PolicyType.Automatic); scrolledWindow.SetPolicy (PolicyType.Never, PolicyType.Automatic);
@ -40,16 +36,9 @@ namespace GtkDemo
Frame frame = new Frame (); Frame frame = new Frame ();
hbox.PackStart (frame, true, true, 0); hbox.PackStart (frame, true, true, 0);
window.ShowAll (); this.ShowAll ();
} }
// private TreeModel CreateModel ()
// {
// ListStore store;
// TreeModel model = new TreeModel ();
// return model;
// }
private ListStore CreateStore () private ListStore CreateStore ()
{ {
// image, name, label, accel // image, name, label, accel
@ -66,8 +55,9 @@ namespace GtkDemo
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
} }
} }

View file

@ -13,8 +13,6 @@
* formatting features. * formatting features.
*/ */
using System; using System;
using System.IO; using System.IO;
@ -23,21 +21,20 @@ using Gtk;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoTextView public class DemoTextView : Gtk.Window
{ {
private Gtk.Window window;
TextView view1; TextView view1;
TextView view2; TextView view2;
public DemoTextView ()
public DemoTextView () : base ("TextView Demo")
{ {
window = new Gtk.Window ("TextView Demo"); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete); this.SetDefaultSize (450,450);
window.SetDefaultSize (450,450); this.BorderWidth = 6;
window.BorderWidth = 0;
VPaned vpaned = new VPaned (); VPaned vpaned = new VPaned ();
vpaned.BorderWidth = 5; vpaned.BorderWidth = 5;
window.Add (vpaned); this.Add (vpaned);
/* For convenience, we just use the autocreated buffer from /* For convenience, we just use the autocreated buffer from
* the first text view; you could also create the buffer * the first text view; you could also create the buffer
@ -66,14 +63,15 @@ namespace GtkDemo
vpaned.ShowAll(); vpaned.ShowAll();
window.ShowAll (); this.ShowAll ();
} }
private TextChildAnchor buttonAnchor; private TextChildAnchor buttonAnchor;
private TextChildAnchor menuAnchor; private TextChildAnchor menuAnchor;
private TextChildAnchor scaleAnchor; private TextChildAnchor scaleAnchor;
private TextChildAnchor animationAnchor; private TextChildAnchor animationAnchor;
private TextChildAnchor entryAnchor; private TextChildAnchor entryAnchor;
private void AttachWidgets (TextView textView) private void AttachWidgets (TextView textView)
{ {
Button button = new Button ("Click Me"); Button button = new Button ("Click Me");
@ -84,11 +82,11 @@ namespace GtkDemo
OptionMenu option = new OptionMenu (); OptionMenu option = new OptionMenu ();
Menu menu = new Menu (); Menu menu = new Menu ();
MenuItem menuItem = new MenuItem ("Option 1"); MenuItem menuItem = new MenuItem ("Option 1");
menu.Append(menuItem); menu.Append (menuItem);
menuItem = new MenuItem ("Option 2"); menuItem = new MenuItem ("Option 2");
menu.Append(menuItem); menu.Append (menuItem);
menuItem = new MenuItem ("Option 3"); menuItem = new MenuItem ("Option 3");
menu.Append(menuItem); menu.Append (menuItem);
option.Menu = menu; option.Menu = menu;
textView.AddChildAtAnchor (option, menuAnchor); textView.AddChildAtAnchor (option, menuAnchor);
menu.ShowAll (); menu.ShowAll ();
@ -106,7 +104,6 @@ namespace GtkDemo
Entry entry = new Entry (); Entry entry = new Entry ();
textView.AddChildAtAnchor (entry, entryAnchor); textView.AddChildAtAnchor (entry, entryAnchor);
image.ShowAll (); image.ShowAll ();
} }
private void CreateTags (TextBuffer buffer) private void CreateTags (TextBuffer buffer)
@ -130,128 +127,128 @@ namespace GtkDemo
* gtk_text_tag_set_priority(). * gtk_text_tag_set_priority().
*/ */
TextTag tag = new TextTag("heading"); TextTag tag = new TextTag ("heading");
tag.Weight = Pango.Weight.Bold; tag.Weight = Pango.Weight.Bold;
tag.Size = (int) Pango.Scale.PangoScale * 15; 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; 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; 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; 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; 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; 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"; tag.Family = "monospace";
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
tag = new TextTag("blue_foreground"); tag = new TextTag ("blue_foreground");
tag.Foreground = "blue"; tag.Foreground = "blue";
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
tag = new TextTag("red_background"); tag = new TextTag ("red_background");
tag.Background = "red"; tag.Background = "red";
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
int gray50_width = 2; int gray50_width = 2;
int gray50_height = 2; int gray50_height = 2;
string gray50_bits = new string ((char) 0x02, (char) 0x01); 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); // 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; // tag.BackgroundStipple = stipple;
// Cannot convert type 'Gdk.Bitmap' to 'Gdk.Pixmap' // 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' // Cannot convert type 'Gdk.Bitmap' to 'Gdk.Pixmap'
// tag.ForegroundStipple = stipple; // 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; 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; 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; tag.PixelsInsideWrap = 10;
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
tag = new TextTag("not_editable"); tag = new TextTag ("not_editable");
tag.Editable = false; 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; 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; 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; tag.WrapMode = WrapMode.None;
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
tag = new TextTag("center"); tag = new TextTag ("center");
tag.Justification = Justification.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; 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.LeftMargin = 50;
tag.RightMargin = 50; tag.RightMargin = 50;
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
tag = new TextTag("strikethrough"); tag = new TextTag ("strikethrough");
tag.Strikethrough = true; tag.Strikethrough = true;
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
tag = new TextTag("underline"); tag = new TextTag ("underline");
tag.Underline = Pango.Underline.Single; 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; 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.Rise = (int) Pango.Scale.PangoScale * 10;
tag.Size = (int) Pango.Scale.PangoScale * 8; 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.Rise = (int) Pango.Scale.PangoScale * -10;
tag.Size = (int) Pango.Scale.PangoScale * 8; 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.WrapMode = WrapMode.Word;
tag.Direction = TextDirection.Rtl; tag.Direction = TextDirection.Rtl;
tag.Indent = 30; tag.Indent = 30;
tag.LeftMargin = 20; tag.LeftMargin = 20;
tag.RightMargin = 20; tag.RightMargin = 20;
buffer.TagTable.Add(tag); buffer.TagTable.Add (tag);
} }
private void InsertText (TextBuffer buffer) private void InsertText (TextBuffer buffer)
@ -277,7 +274,7 @@ namespace GtkDemo
TextIter insertIter; TextIter insertIter;
insertIter = buffer.GetIterAtOffset (0); 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"); "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"}); InsertWithTagsByName (buffer, "Font styles. ", new string[] {"heading"});
@ -392,29 +389,29 @@ namespace GtkDemo
TextIter insertIter, beginIter, endIter; TextIter insertIter, beginIter, endIter;
int begin, end; int begin, end;
begin = buffer.CharCount; begin = buffer.CharCount;
insertIter = buffer.GetIterAtMark(buffer.InsertMark); insertIter = buffer.GetIterAtMark(buffer.InsertMark);
buffer.Insert (insertIter, insertText); buffer.Insert (insertIter, insertText);
end = buffer.CharCount; end = buffer.CharCount;
foreach (string fontItem in fontName){ foreach (string fontItem in fontName) {
endIter = buffer.GetIterAtOffset (end); endIter = buffer.GetIterAtOffset (end);
beginIter = buffer.GetIterAtOffset (begin); beginIter = buffer.GetIterAtOffset (begin);
buffer.ApplyTag (fontItem, beginIter, endIter);} buffer.ApplyTag (fontItem, beginIter, endIter);
}
} }
private void Insert (TextBuffer buffer , string insertText) private void Insert (TextBuffer buffer , string insertText)
{ {
TextIter insertIter; TextIter insertIter;
insertIter = buffer.GetIterAtMark (buffer.InsertMark);
insertIter = buffer.GetIterAtMark(buffer.InsertMark);
buffer.Insert (insertIter, insertText); buffer.Insert (insertIter, insertText);
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
private void RecursiveAttach (int depth, TextView view, TextChildAnchor anchor) 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 */ /* Event box is to add a black border around each child view */
EventBox eventBox = new EventBox (); EventBox eventBox = new EventBox ();
Gdk.Color blackColor = new Gdk.Color (0x0, 0x0, 0x0); 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); Alignment align = new Alignment (0.5f, 0.5f, 1.0f, 1.0f);
align.BorderWidth = 1; align.BorderWidth = 1;
@ -436,8 +433,7 @@ namespace GtkDemo
view.AddChildAtAnchor (eventBox, anchor); view.AddChildAtAnchor (eventBox, anchor);
RecursiveAttach(depth+1, childView, anchor); RecursiveAttach (depth+1, childView, anchor);
} }
private void EasterEggCB (object o, EventArgs args) private void EasterEggCB (object o, EventArgs args)
@ -445,16 +441,16 @@ namespace GtkDemo
TextIter insertIter; TextIter insertIter;
TextBuffer bufferCB = new TextBuffer (null); 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); insertIter = bufferCB.GetIterAtMark(bufferCB.InsertMark);
TextChildAnchor anchor = bufferCB.CreateChildAnchor (insertIter); 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); TextView viewCB = new TextView (bufferCB);
RecursiveAttach(0, viewCB, anchor); RecursiveAttach (0, viewCB, anchor);
Gtk.Window window = new Gtk.Window (null); 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); scrolledWindow.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
window.Add (scrolledWindow); window.Add (scrolledWindow);
@ -462,7 +458,6 @@ namespace GtkDemo
window.SetDefaultSize (300, 400); window.SetDefaultSize (300, 400);
window.ShowAll (); window.ShowAll ();
} }
} }
} }

View file

@ -22,21 +22,19 @@ using GLib;
namespace GtkDemo namespace GtkDemo
{ {
public class DemoTreeStore : Gtk.Window
public class DemoTreeStore
{ {
private Window window;
private TreeStore store; private TreeStore store;
public DemoTreeStore ()
public DemoTreeStore () : base ("TreeStore Demo")
{ {
window = new Window ("TreeStore Demo"); this.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
VBox vbox = new VBox (false, 8); VBox vbox = new VBox (false, 8);
vbox.BorderWidth = 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 scrolledWindow = new ScrolledWindow ();
scrolledWindow.ShadowType = ShadowType.EtchedIn; scrolledWindow.ShadowType = ShadowType.EtchedIn;
@ -44,7 +42,7 @@ namespace GtkDemo
vbox.PackStart (scrolledWindow, true, true, 0); vbox.PackStart (scrolledWindow, true, true, 0);
// create model // create model
CreateModel(); CreateModel ();
// create tree view // create tree view
TreeView treeView = new TreeView (store); TreeView treeView = new TreeView (store);
@ -60,10 +58,8 @@ namespace GtkDemo
treeView.ExpandRow (new TreePath (i.ToString ()), false); treeView.ExpandRow (new TreePath (i.ToString ()), false);
} }
window.SetDefaultSize (650, 400); this.SetDefaultSize (650, 400);
this.ShowAll ();
window.ShowAll ();
} }
private void ItemToggled (object o, ToggledArgs args) private void ItemToggled (object o, ToggledArgs args)
@ -72,11 +68,11 @@ namespace GtkDemo
int column = (int) cellRendererToggle.Data["column"]; int column = (int) cellRendererToggle.Data["column"];
Gtk.TreeIter iter; Gtk.TreeIter iter;
if (store.GetIterFromString(out iter, args.Path)) if (store.GetIterFromString (out iter, args.Path))
{ {
bool val = (bool) store.GetValue(iter, column); bool val = (bool) store.GetValue (iter, column);
Console.WriteLine("toggled {0} with value {1}", args.Path, !val); Console.WriteLine ("toggled {0} with value {1}", args.Path, !val);
store.SetValue(iter, column, !val); store.SetValue (iter, column, !val);
} }
} }
@ -87,9 +83,9 @@ namespace GtkDemo
rendererText.Xalign = 0.0f; rendererText.Xalign = 0.0f;
GLib.Object ugly = (GLib.Object) rendererText; GLib.Object ugly = (GLib.Object) rendererText;
ugly.Data ["column"] = Column.HolidayName; ugly.Data ["column"] = Column.HolidayName;
TreeViewColumn column = new TreeViewColumn("Holiday", rendererText, TreeViewColumn column = new TreeViewColumn ("Holiday", rendererText,
"text", Column.HolidayName); "text", Column.HolidayName);
treeView.InsertColumn(column, (int) Column.HolidayName); treeView.InsertColumn (column, (int) Column.HolidayName);
// alex column // alex column
CellRendererToggle rendererToggle = new CellRendererToggle (); CellRendererToggle rendererToggle = new CellRendererToggle ();
@ -100,12 +96,11 @@ namespace GtkDemo
rendererToggle.Visible = true; rendererToggle.Visible = true;
rendererToggle.Activatable = true; rendererToggle.Activatable = true;
rendererToggle.Active = 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.Sizing = TreeViewColumnSizing.Fixed;
column.FixedWidth = 50; column.FixedWidth = 50;
column.Clickable = true; column.Clickable = true;
treeView.InsertColumn(column, (int) Column.Alex); treeView.InsertColumn (column, (int) Column.Alex);
// havoc column // havoc column
rendererToggle = new CellRendererToggle (); rendererToggle = new CellRendererToggle ();
@ -113,11 +108,11 @@ namespace GtkDemo
ugly = (GLib.Object) rendererToggle; ugly = (GLib.Object) rendererToggle;
ugly.Data ["column"] = Column.Havoc; ugly.Data ["column"] = Column.Havoc;
rendererToggle.Toggled += new ToggledHandler (ItemToggled); 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; column.Visible = true;
rendererToggle.Activatable = true; rendererToggle.Activatable = true;
rendererToggle.Active = true; rendererToggle.Active = true;
treeView.InsertColumn(column, (int) Column.Havoc); treeView.InsertColumn (column, (int) Column.Havoc);
column.Sizing = TreeViewColumnSizing.Fixed; column.Sizing = TreeViewColumnSizing.Fixed;
column.FixedWidth = 50; column.FixedWidth = 50;
column.Clickable = true; column.Clickable = true;
@ -128,11 +123,11 @@ namespace GtkDemo
ugly = (GLib.Object) rendererToggle; ugly = (GLib.Object) rendererToggle;
ugly.Data ["column"] = Column.Tim; ugly.Data ["column"] = Column.Tim;
rendererToggle.Toggled += new ToggledHandler (ItemToggled); 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; column.Visible = true;
rendererToggle.Activatable = true; rendererToggle.Activatable = true;
rendererToggle.Active = true; rendererToggle.Active = true;
treeView.InsertColumn(column, (int) Column.Tim); treeView.InsertColumn (column, (int) Column.Tim);
column.Sizing = TreeViewColumnSizing.Fixed; column.Sizing = TreeViewColumnSizing.Fixed;
column.FixedWidth = 50; column.FixedWidth = 50;
column.Clickable = true; column.Clickable = true;
@ -143,11 +138,11 @@ namespace GtkDemo
ugly = (GLib.Object) rendererToggle; ugly = (GLib.Object) rendererToggle;
ugly.Data ["column"] = Column.Owen; ugly.Data ["column"] = Column.Owen;
rendererToggle.Toggled += new ToggledHandler (ItemToggled); 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; column.Visible = true;
rendererToggle.Activatable = true; rendererToggle.Activatable = true;
rendererToggle.Active = true; rendererToggle.Active = true;
treeView.InsertColumn(column, (int) Column.Owen); treeView.InsertColumn (column, (int) Column.Owen);
column.Sizing = TreeViewColumnSizing.Fixed; column.Sizing = TreeViewColumnSizing.Fixed;
column.FixedWidth = 50; column.FixedWidth = 50;
column.Clickable = true; column.Clickable = true;
@ -158,21 +153,21 @@ namespace GtkDemo
ugly = (GLib.Object) rendererToggle; ugly = (GLib.Object) rendererToggle;
ugly.Data ["column"] = Column.Dave; ugly.Data ["column"] = Column.Dave;
rendererToggle.Toggled += new ToggledHandler (ItemToggled); 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; column.Visible = true;
rendererToggle.Activatable = true; rendererToggle.Activatable = true;
rendererToggle.Active = true; rendererToggle.Active = true;
treeView.InsertColumn(column, (int) Column.Dave); treeView.InsertColumn (column, (int) Column.Dave);
column.Sizing = TreeViewColumnSizing.Fixed; column.Sizing = TreeViewColumnSizing.Fixed;
column.FixedWidth = 50; column.FixedWidth = 50;
column.Clickable = true; column.Clickable = true;
} }
private void WindowDelete (object o, DeleteEventArgs args) private void WindowDelete (object o, DeleteEventArgs args)
{ {
window.Hide (); this.Hide ();
window.Destroy (); this.Destroy ();
args.RetVal = true;
} }
private void CreateModel () private void CreateModel ()
@ -189,7 +184,6 @@ namespace GtkDemo
typeof(bool)); typeof(bool));
// add data to the tree store // add data to the tree store
// STUCK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
foreach (MyTreeItem month in toplevel) foreach (MyTreeItem month in toplevel)
{ {
@ -212,11 +206,8 @@ namespace GtkDemo
hollyday.Owen, hollyday.Owen,
hollyday.Dave, hollyday.Dave,
true); true);
} }
} }
} }
// tree data // tree data
@ -327,7 +318,6 @@ namespace GtkDemo
}; };
// TreeItem structure // TreeItem structure
// report bug array mismatch declaration
public class MyTreeItem public class MyTreeItem
{ {
public string Label; public string Label;

18
sample/GtkDemo/TODO Normal file
View file

@ -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