3 namespace Search
.Tiles
{
5 public class DetailsPane
: Gtk
.Table
{
7 public DetailsPane () : base (1, 2, false)
9 RowSpacing
= ColumnSpacing
= 6;
12 icon
= new Gtk
.Image ();
14 Attach (icon
, 0, 1, 0, 1, fill
, fill
, 0, 0);
16 SizeRequested
+= DetailsSizeRequested
;
19 private Gtk
.Image icon
;
20 public Gtk
.Image Icon
{
24 private Gtk
.Label snippet
;
25 public Gtk
.Label Snippet
{
26 get { return snippet; }
29 bool maximized
= false;
31 // FIXME: overriding OnSizeRequested directly results in a 0x0 req
33 private void DetailsSizeRequested (object obj
, Gtk
.SizeRequestedArgs args
)
38 Gtk
.Table
.TableChild
[,] children
= new Gtk
.Table
.TableChild
[NColumns
, NRows
];
40 foreach (Gtk
.Widget child
in Children
) {
41 Gtk
.Table
.TableChild tc
= this[child
] as Gtk
.Table
.TableChild
;
42 children
[tc
.LeftAttach
, tc
.TopAttach
] = tc
;
45 // Expand the icon down to the bottom or the first label
46 if (children
[0, 0] != null && children
[0, 0].Child
== icon
) {
48 for (max_icon_row
= 1; max_icon_row
< NRows
; max_icon_row
++) {
49 if (children
[0, max_icon_row
] != null)
53 children
[0, 0].BottomAttach
= max_icon_row
;
56 // Expand all labels (except in column 0) rightward
57 for (uint row
= 0; row
< NRows
; row
++) {
58 for (uint col
= 1; col
< NColumns
; col
++) {
59 if (children
[col
, row
] == null ||
60 !(children
[col
, row
].Child
is Gtk
.Label
))
63 while (end
< NColumns
&&
64 children
[end
, row
] == null)
67 children
[col
, row
].RightAttach
= end
;
71 // Vertically expand only the bottom row
72 for (uint row
= 0; row
< NRows
; row
++) {
73 for (uint col
= 1; col
< NColumns
; col
++) {
74 if (children
[col
, row
] == null)
76 children
[col
, row
].YOptions
= (row
== NRows
- 1) ? expand
: fill
;
83 private const Gtk
.AttachOptions expand
= Gtk
.AttachOptions
.Expand
| Gtk
.AttachOptions
.Fill
;
84 private const Gtk
.AttachOptions fill
= Gtk
.AttachOptions
.Fill
;
86 private uint current_row
= 0;
88 private Gtk
.Label
AddGrayLabel (string text
, uint row
, uint column
)
90 Gtk
.Label label
= WidgetFu
.NewGrayLabel (text
);
92 Attach (label
, column
, column
+ 1, row
, row
+ 1, fill
, fill
, 0, 0);
97 private Gtk
.Label
AddLabel (string text
, uint row
, uint column
)
99 Gtk
.Label label
= WidgetFu
.NewLabel (text
);
100 label
.Selectable
= true;
101 WidgetFu
.EllipsizeLabel (label
);
103 Attach (label
, column
, column
+ 1, row
, row
+ 1, expand
, fill
, 0, 0);
108 private Gtk
.Label
AddBoldLabel (string text
, uint row
, uint column
)
110 Gtk
.Label label
= WidgetFu
.NewBoldLabel (text
);
111 WidgetFu
.EllipsizeLabel (label
);
113 Attach (label
, column
, column
+ 1, row
, row
+ 1, expand
, fill
, 0, 0);
118 public Gtk
.Label
AddTitleLabel (string text
)
120 Gtk
.Label label
= AddBoldLabel (text
, current_row
++, 1);
121 label
.Selectable
= true;
125 public Gtk
.Label
AddTextLabel (string text
)
127 Gtk
.Label label
= AddLabel (text
, current_row
++, 1);
131 public void AddLabelPair (string label
, string text
)
133 AddGrayLabel (label
, current_row
, 1);
134 AddLabel (text
, current_row
++, 2);
137 public Gtk
.Label
AddSnippet ()
139 snippet
= WidgetFu
.NewLabel ();
140 snippet
.Selectable
= true;
141 WidgetFu
.EllipsizeLabel (snippet
);
143 Attach (snippet
, 1, 2, current_row
, ++current_row
, expand
, fill
, 48, 0);
149 public Gtk
.Label
AddNewLine ()
151 Gtk
.Label label
= WidgetFu
.NewLabel ("");
153 Attach (label
, 1, 2, current_row
, ++current_row
, fill
, fill
, 0, 0);
157 public Gtk
.Label
AddFinalLine ()
159 Gtk
.Label label
= WidgetFu
.NewLabel ("");
161 Attach (label
, 1, 2, current_row
, ++current_row
, expand
, expand
, 0, 0);
165 public void GotSnippet (string text
)
167 snippet
.Markup
= text
;