[banshee] [TrackEditor] Show a tooltip when the property is truncated (bgo#589782)
- From: Alexander Kojevnikov <alexk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee] [TrackEditor] Show a tooltip when the property is truncated (bgo#589782)
- Date: Thu, 10 Sep 2009 13:00:05 +0000 (UTC)
commit 5b39d103777f0bfbf79b406f9fdd371a212cbea5
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date: Thu Sep 10 22:57:26 2009 +1000
[TrackEditor] Show a tooltip when the property is truncated (bgo#589782)
.../Banshee.Gui.TrackEditor/StatisticsPage.cs | 41 +++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
index 2e2cff5..cd884f0 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
@@ -52,6 +52,7 @@ namespace Banshee.Gui.TrackEditor
public class StatisticsPage : ScrolledWindow, ITrackEditorPage
{
private CellRendererText name_renderer;
+ private CellRendererText value_renderer;
private ListStore model;
private TreeView view;
@@ -64,6 +65,8 @@ namespace Banshee.Gui.TrackEditor
view = new FixedTreeView (model);
view.HeadersVisible = false;
view.RowSeparatorFunc = new TreeViewRowSeparatorFunc (RowSeparatorFunc);
+ view.HasTooltip = true;
+ view.QueryTooltip += HandleQueryTooltip;
name_renderer = new CellRendererText ();
name_renderer.Alignment = Pango.Alignment.Right;
@@ -71,7 +74,7 @@ namespace Banshee.Gui.TrackEditor
name_renderer.Xalign = 1.0f;
name_renderer.Scale = Pango.Scale.Small;
- CellRendererText value_renderer = new CellRendererText ();
+ value_renderer = new CellRendererText ();
value_renderer.Ellipsize = Pango.EllipsizeMode.End;
value_renderer.Editable = true;
value_renderer.Scale = Pango.Scale.Small;
@@ -93,6 +96,42 @@ namespace Banshee.Gui.TrackEditor
{
return (bool)model.GetValue (iter, 2);
}
+
+ private void HandleQueryTooltip(object o, QueryTooltipArgs args)
+ {
+ TreePath path;
+ TreeIter iter;
+ if (view.GetPathAtPos (args.X, args.Y, out path) && view.Model.GetIter (out iter, path)) {
+ string text = (string)view.Model.GetValue (iter, 1);
+ if (!String.IsNullOrEmpty (text)) {
+ using (var layout = new Pango.Layout (view.PangoContext)) {
+ layout.FontDescription = value_renderer.FontDesc;
+ layout.SetText (text);
+ layout.Attributes = new Pango.AttrList ();
+ layout.Attributes.Insert (new Pango.AttrScale (value_renderer.Scale));
+
+ int width, height;
+ layout.GetPixelSize (out width, out height);
+
+ var column = view.GetColumn (1);
+ var column_width = column.Width - 2 * value_renderer.Xpad -
+ (int)view.StyleGetProperty ("horizontal-separator") -
+ 2 * (int)view.StyleGetProperty ("focus-line-width");
+
+ if (width > column_width) {
+ args.Tooltip.Text = text;
+ view.SetTooltipCell (args.Tooltip, path, column, value_renderer);
+ args.RetVal = true;
+ }
+ }
+ }
+ }
+
+ // Work around ref counting SIGSEGV, see http://bugzilla.gnome.org/show_bug.cgi?id=478519#c9
+ if (args.Tooltip != null) {
+ args.Tooltip.Dispose ();
+ }
+ }
protected override void OnStyleSet (Style previous_style)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]