cvsimport
[beagle.git] / search / Pages / Base.cs
blobff6147a1220058e1bc159ea6827c2068f17ba08d
1 using Gtk;
2 using System;
3 using Mono.Unix;
5 namespace Search.Pages {
7 public class Base : EventBox {
9 private static Gdk.Pixbuf arrow = Beagle.Images.GetPixbuf ("tip-arrow.png");
11 Gtk.Fixed fixed_widget;
12 Gtk.Table table;
13 Gtk.Image headerIcon;
14 Gtk.Label header;
16 public Base ()
18 fixed_widget = new Fixed ();
19 fixed_widget.HasWindow = true;
20 Add (fixed_widget);
22 table = new Gtk.Table (1, 2, false);
23 table.RowSpacing = table.ColumnSpacing = 12;
25 headerIcon = new Gtk.Image ();
26 headerIcon.Yalign = 0.0f;
27 table.Attach (headerIcon, 0, 1, 0, 1,
28 0, Gtk.AttachOptions.Fill,
29 0, 0);
31 header = new Gtk.Label ();
32 header.SetAlignment (0.0f, 0.5f);
33 table.Attach (header, 1, 2, 0, 1,
34 Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
35 Gtk.AttachOptions.Fill,
36 0, 0);
38 fixed_widget.Add (table);
39 fixed_widget.ShowAll ();
42 protected override void OnRealized ()
44 base.OnRealized ();
45 ModifyBg (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Normal));
48 public Gdk.Pixbuf HeaderIcon {
49 set { headerIcon.Pixbuf = value; }
52 public string HeaderIconStock {
53 set { headerIcon.SetFromStock (value, Gtk.IconSize.Dnd); }
56 public string HeaderMarkup {
57 set { header.Markup = value; }
60 public void Append (string tip)
62 uint row = table.NRows;
63 Gtk.Image image;
64 Gtk.Label label;
66 image = new Gtk.Image (arrow);
67 image.Yalign = 0.0f;
68 image.Xalign = 1.0f;
69 image.Show ();
70 table.Attach (image, 0, 1, row, row + 1,
71 Gtk.AttachOptions.Fill,
72 Gtk.AttachOptions.Fill,
73 0, 0);
75 label = new Gtk.Label ();
76 label.Markup = tip;
77 label.SetAlignment (0.0f, 0.5f);
78 label.LineWrap = true;
79 label.ModifyFg (Gtk.StateType.Normal, label.Style.Foreground (Gtk.StateType.Insensitive));
80 label.Show ();
81 table.Attach (label, 1, 2, row, row + 1,
82 Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
83 0, 0, 0);
87 public void Append (Gtk.Widget widget)
89 uint row = table.NRows;
91 table.Attach (widget, 1, 2, row, row + 1, 0, 0, 0, 0);
94 protected override void OnSizeRequested (ref Gtk.Requisition req)
96 req = table.SizeRequest ();
99 protected override void OnSizeAllocated (Gdk.Rectangle allocation)
101 base.OnSizeAllocated (allocation);
103 Gtk.Requisition tableReq = table.ChildRequisition;
104 allocation.X = Math.Max ((allocation.Width - tableReq.Width) / 2, 0);
105 allocation.Y = Math.Max ((allocation.Height - tableReq.Height) / 2, 0);
106 allocation.Width = tableReq.Width;
107 allocation.Height = tableReq.Height;
108 table.SizeAllocate (allocation);