GtkSharp/sample/GtkDemo/DemoStockBrowser.cs
Daniel Kornhauser Eisenberg b3a7fd2924 2003-10-30 Daniel Kornhauser Eisenberg <dkor@alum.mit.edu>
* sample/GtkDemo/DemoApplicationWindow.cs : New sample, Unfinished, 5%  Done
* sample/GtkDemo/DemoButtonBox.cs :      New sample,
* sample/GtkDemo/DemoColorSelection.cs : New sample,
* sample/GtkDemo/DemoDialog.cs :         New sample,
* sample/GtkDemo/DemoDrawingArea.cs :    New sample,
* sample/GtkDemo/DemoEditableCells.cs :  New sample, Needs clean up
* sample/GtkDemo/DemoImages.cs :         New sample, Unfinished, 75% Done
* sample/GtkDemo/DemoItemFactory.cs :    New sample, Unfinished, 5%  Done
* sample/GtkDemo/DemoListStore.cs :      New sample,
* sample/GtkDemo/DemoMain.cs :           New sample, Unifnished, 60% Done
* sample/GtkDemo/DemoMenus.cs :          New sample,
* sample/GtkDemo/DemoPanes.cs :          New sample,
* sample/GtkDemo/DemoPixbuf.cs :         New sample, Needs clean up
* sample/GtkDemo/DemoSizeGroup.cs :      New sample,
* sample/GtkDemo/DemoStockBrowser.cs :   New sample, Unfinished, 20% Done
* sample/GtkDemo/DemoTextView.cs :       New sample, Unfinished, 99% Done
* sample/GtkDemo/DemoTreeStore.cs :      New sample, Unfinished, 95% Done
* sample/GtkDemo/images : Several Images for the samples
* sample/GtkDemo/Makefile : Very simple Makefile
* sample/GtkDemo/README : Mentions explicitely unfinished state of port

svn path=/trunk/gtk-sharp/; revision=19489
2003-10-30 23:57:41 +00:00

75 lines
1.8 KiB
C#

//
// StockBrowser.cs, port of stock_browser.c from gtk-demo
//
// Author: Daniel Kornhauser <dkor@media.mit.edu>
//
// (C) 2003 Ximian, Inc.
using System;
using Gtk;
using GtkSharp;
namespace GtkDemo
{
public class DemoStockBrowser
{
private Gtk.Window window;
public DemoStockBrowser ()
{
window = new Gtk.Window ("Stock Item Browser Demo");
window.SetDefaultSize (600, 400);
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
window.BorderWidth = 8;
HBox hbox = new HBox (false, 8);
window.Add (hbox);
ScrolledWindow scrolledWindow = new ScrolledWindow (null, null);
scrolledWindow.SetPolicy (PolicyType.Never, PolicyType.Automatic);
hbox.PackStart (scrolledWindow, true, true, 0);
TreeView list = new TreeView ();
list.AppendColumn ("Icon", new CellRendererPixbuf (), "pixbuf", 0);
list.AppendColumn ("Name", new CellRendererText (), "text", 1);
list.AppendColumn ("Label", new CellRendererText (), "text", 2);
list.AppendColumn ("Accel", new CellRendererText (), "text", 3);
list.Model = CreateStore ();
scrolledWindow.Add (list);
Frame frame = new Frame ();
hbox.PackStart (frame, true, true, 0);
window.ShowAll ();
}
// private TreeModel CreateModel ()
// {
// ListStore store;
// TreeModel model = new TreeModel ();
// return model;
// }
private ListStore CreateStore ()
{
// image, name, label, accel
ListStore store = new Gtk.ListStore (typeof (Gdk.Pixbuf), typeof(string), typeof(string), typeof(string));
for (int i =1; i < 10; i++)
{
Image icon = new Image ("images/MonoIcon.png");
store.AppendValues (icon, "Gtk.Stock.Ok", "Ok", "_Ok");
}
return store;
}
private void WindowDelete (object o, DeleteEventArgs args)
{
window.Hide ();
window.Destroy ();
}
}
}