[banshee: 54/61] [InternetArchive] Make pretty sections collapsable
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee: 54/61] [InternetArchive] Make pretty sections collapsable
- Date: Tue, 3 Nov 2009 06:32:23 +0000 (UTC)
commit b6a00ce81b1e2cbf1538017213e494146e973ad6
Author: Gabriel Burt <gabriel burt gmail com>
Date: Fri Oct 16 18:55:12 2009 -0700
[InternetArchive] Make pretty sections collapsable
.../Banshee.InternetArchive/DetailsView.cs | 60 +++++++++++++++----
1 files changed, 47 insertions(+), 13 deletions(-)
---
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs
index 57ea9cc..788f626 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs
@@ -101,13 +101,20 @@ namespace Banshee.InternetArchive
private Widget CreateSection (string label, Widget child)
{
- var section = new VBox () { Spacing = 6 };
- var header = new SectionHeader (label);
+ var section = new Section (label, child);
+ return section;
+ }
- section.PackStart (header, false, false, 0);
- section.PackStart (child, false, false, 0);
+ private class Section : VBox
+ {
+ public Section (string label, Widget child)
+ {
+ Spacing = 6;
- return section;
+ var header = new SectionHeader (label, child);
+ PackStart (header, false, false, 0);
+ PackStart (child, false, false, 0);
+ }
}
private class SectionHeader : EventBox
@@ -115,14 +122,17 @@ namespace Banshee.InternetArchive
HBox box;
Arrow arrow;
Label label;
+ Widget child;
- public SectionHeader (string headerString)
+ public SectionHeader (string headerString, Widget child)
{
+ this.child = child;
+
AppPaintable = true;
+ CanFocus = true;
box = new HBox ();
box.Spacing = 6;
- Child = box;
box.BorderWidth = 4;
label = new Label ("<b>" + headerString + "</b>") { Xalign = 0f, UseMarkup = true };
arrow = new Arrow (ArrowType.Down, ShadowType.None);
@@ -140,6 +150,36 @@ namespace Banshee.InternetArchive
changing_style = false;
}
};
+
+ Child = box;
+
+ ButtonPressEvent += (o, a) => Toggle ();
+ KeyPressEvent += (o, a) => {
+ var key = a.Event.Key;
+ switch (key) {
+ case Gdk.Key.Return:
+ case Gdk.Key.KP_Enter:
+ case Gdk.Key.space:
+ Toggle ();
+ a.RetVal = true;
+ break;
+ }
+ };
+ }
+
+ private void Toggle ()
+ {
+ Expanded = !Expanded;
+ }
+
+ private bool expanded = true;
+ private bool Expanded {
+ get { return expanded; }
+ set {
+ arrow.ArrowType = value ? ArrowType.Down : ArrowType.Right;
+ child.Visible = value;
+ expanded = value;
+ }
}
}
@@ -150,12 +190,6 @@ namespace Banshee.InternetArchive
vbox.Spacing = 6;
vbox.BorderWidth = 2;
- // Title
- /*var title = new Label () {
- Xalign = 0f,
- Markup = String.Format ("<big><b>{0}</b></big>", GLib.Markup.EscapeText (item.Title))
- };*/
-
// Description
var desc = new Hyena.Widgets.WrapLabel () {
//Markup = String.Format ("<small>{0}</small>", GLib.Markup.EscapeText (Hyena.StringUtil.RemoveHtml (details.Description)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]