Dont add null mimetypes. Fixes bgo# 337431. The patch hasnt been officially accepted...
[beagle.git] / search / Panes.cs
blobdaef43426e0f1c14ba979762909317a736ba011f
1 using Gtk;
2 using Gdk;
3 using System;
4 using System.Collections;
6 namespace Search {
8 public class Panes : Gtk.VPaned {
10 Gtk.ScrolledWindow mainSW, detailsSW;
11 WhiteBox main, details;
13 public Panes ()
15 Gtk.Viewport vp;
17 mainSW = new Gtk.ScrolledWindow ();
18 mainSW.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Always);
19 mainSW.ShadowType = Gtk.ShadowType.In;
20 mainSW.SizeAllocated += MainResized;
21 Pack1 (mainSW, true, false);
23 vp = new Gtk.Viewport (null, null);
24 vp.ResizeMode = Gtk.ResizeMode.Parent;
25 vp.ShadowType = ShadowType.None;
26 mainSW.Add (vp);
27 vp.Show ();
29 main = new WhiteBox ();
30 vp.Add (main);
31 main.Show ();
33 detailsSW = new Gtk.ScrolledWindow ();
34 detailsSW.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
35 detailsSW.WidthRequest = 0;
36 detailsSW.NoShowAll = true;
37 detailsSW.ShadowType = Gtk.ShadowType.In;
38 Pack2 (detailsSW, false, false);
40 vp = new Gtk.Viewport (null, null);
41 vp.ShadowType = ShadowType.None;
42 detailsSW.Add (vp);
43 vp.Show ();
45 details = new WhiteBox ();
46 vp.Add (details);
47 details.Show ();
50 public Gtk.Widget MainContents {
51 get {
52 return main.Child;
54 set {
55 if (main.Child != null)
56 main.Remove (main.Child);
57 if (value != null) {
58 main.Add (value);
59 if (value is Container)
60 ((Container)value).FocusVadjustment = mainSW.Vadjustment;
65 public Gtk.Widget Details {
66 get {
67 return details.Child;
69 set {
70 if (details.Child != null)
71 details.Remove (details.Child);
72 if (value != null) {
73 details.Add (value);
74 detailsSW.Show ();
75 } else
76 detailsSW.Hide ();
80 private void MainResized (object obj, Gtk.SizeAllocatedArgs args)
82 // If the details pane pops up and covers the selected tile,
83 // fix it.
85 Gtk.Container mainChild = main.Child as Gtk.Container;
86 if (mainChild != null) {
87 Gtk.Widget focusChild = mainChild.FocusChild;
88 mainChild.FocusChild = null;
89 mainChild.FocusChild = focusChild;
93 public class WhiteBox : Gtk.EventBox
95 public WhiteBox () : base ()
97 AppPaintable = true;
100 protected override bool OnExposeEvent (Gdk.EventExpose evt)
102 if (!IsDrawable)
103 return false;
105 if (evt.Window == GdkWindow) {
106 GdkWindow.DrawRectangle (Style.BaseGC (State), true,
107 evt.Area.X, evt.Area.Y,
108 evt.Area.Width, evt.Area.Height);
111 if (Child != null)
112 PropagateExpose (Child, evt);
114 return false;