5 namespace Cairo.Snippets
7 public class CairoSnippetsGtk
12 DrawingArea da = new DrawingArea ();
14 Snippets snips = new Snippets ();
17 public static void Main(string[] args)
20 new CairoSnippetsGtk ();
24 public CairoSnippetsGtk ()
26 Window w = new Window ("Cairo snippets");
27 w.SetDefaultSize (width, height);
28 w.DeleteEvent += delegate { Application.Quit (); };
30 HPaned hpane = new HPaned ();
31 ScrolledWindow sw = new ScrolledWindow ();
32 TreeView tv = new TreeView ();
33 tv.HeadersVisible = false;
34 tv.AppendColumn ("snippets", new CellRendererText (), "text", 0);
35 tv.Model = GetModel ();
36 tv.Selection.Changed += OnSelectionChanged;
39 da = new DrawingArea ();
40 da.ExposeEvent += OnExposed;
42 hpane.Position = width / 2;
50 ListStore store = new ListStore (typeof (string));
51 foreach (string s in Snippets.snippets)
52 store.AppendValues (s);
56 void OnExposed (object sender, ExposeEventArgs e)
58 Context cr = Gdk.CairoHelper.Create (da.GdkWindow);
61 da.GdkWindow.GetSize (out w, out h);
64 cr.ColorRgb = new Color (1, 1, 1 );
65 cr.Rectangle (0, 0, w, h);
68 cr.ColorRgb = new Color (0, 0, 0);
70 Snippets.InvokeSnippet (snips, selected, cr, w, h);
75 void OnSelectionChanged (object sender, EventArgs e)
79 TreeSelection selection = sender as TreeSelection;
81 if (selection.GetSelected (out model, out iter))
83 selected = (string) model.GetValue (iter, 0);