banshee r4623 - in trunk/banshee: . src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data src/Libraries/Hyena.Gui/Hyena.Data.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView



Author: gburt
Date: Mon Sep 29 16:03:41 2008
New Revision: 4623
URL: http://svn.gnome.org/viewvc/banshee?rev=4623&view=rev

Log:
2008-09-29  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs:
	Remove a bunch of old, commented-out code.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs:
	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/IInteractiveCell.cs: Whitespace

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
	Factor some useful bits out of ProxyEventToCell that can be reused for
	tooltip code.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs: Implement
	tooltips for ListView for ellipsized ColumnCellText cells, but comment it
	out for now because there is a segfault bug in Gtk+ or Gtk# that rears its
	head once in a while.

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs: Add public
	UpdateText method and IsEllipsized and Text properties.



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/IInteractiveCell.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs

Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs	Mon Sep 29 16:03:41 2008
@@ -244,56 +244,5 @@
         {
             return Provider.Refresh (this);
         }
-
-        public static void DeleteWithFeedId (long feed_id)
-        {
-            /*PodcastItem item = Provider.FetchFirstMatching (String.Format (
-                "primarysourceid = {0} and externalid = {1}", primary_id, feed_id
-            ));
-
-            if (item != null) {
-                item.Delete ();
-            }*/
-        }
-
-        /*public string Title {
-            get { return item.Title; }
-        }
-        
-        public string PodcastTitle {
-            get { return item.Feed.Title; }
-        }
-        
-        [VirtualDatabaseColumn ("PubDate", "PodcastItems", "TrackID", "TrackID")]
-        public DateTime PubDate {
-            get { return item.PubDate; }
-            set { item.PubDate = value; }
-        }
-        
-        [DatabaseColumn]
-        public string Author {
-            get { return item.Author; }
-            set { item.Author = value; }
-        }
-        
-        [DatabaseColumn ("FeedItemID", Constraints = DatabaseColumnConstraints.NotNull)]
-        public long FeedItemID {
-            get { return feedItemID; }
-            private set { feedItemID = value; }
-        }
-
-        [DatabaseColumn ("New", Constraints = DatabaseColumnConstraints.NotNull)]   
-        public bool New {
-            get { return (_new != 0) ? true : false; }
-            set { _new = (value) ? 1 : 0; }
-        }
-        
-        [DatabaseColumn ("Position", Constraints = DatabaseColumnConstraints.NotNull)]
-        public int Position {
-            get { return position; }
-            private set { 
-                position = (value < 0) ? 0 : value;
-            }
-        }        */
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs	Mon Sep 29 16:03:41 2008
@@ -52,7 +52,7 @@
             Gdk.Rectangle area = new Gdk.Rectangle (0, 0, context.Area.Width, context.Area.Height);
             
             // FIXME: Compute font height and set to renderer.Size
-            
+
             renderer.Value = Value;
             renderer.Render (context.Context, area, context.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state), 
                 hover_bound == BoundObjectParent && hover_bound != null, hover_value, 0.8, 0.45, 0.35);

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs	Mon Sep 29 16:03:41 2008
@@ -49,6 +49,7 @@
         private int text_height;
         private string text_format = null;
         protected string MinString, MaxString;
+        private string last_text = null;
         
         public ColumnCellText (string property, bool expand) : base (property, expand)
         {
@@ -69,7 +70,26 @@
     
         public override void Render (CellContext context, StateType state, double cellWidth, double cellHeight)
         {
-            string text = GetText (BoundObject);
+            UpdateText (context, cellWidth);
+            if (String.IsNullOrEmpty (last_text)) {
+                return;
+            }
+            
+            context.Context.Rectangle (0, 0, cellWidth, cellHeight);
+            context.Context.Clip ();
+            context.Context.MoveTo (Spacing, ((int)cellHeight - text_height) / 2);
+            Cairo.Color color = context.Theme.Colors.GetWidgetColor (
+                context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, state);
+            color.A = (!context.Sensitive) ? 0.3 : opacity;
+            context.Context.Color = color;
+
+            PangoCairoHelper.ShowLayout (context.Context, context.Layout);
+            context.Context.ResetClip ();
+        }
+
+        public void UpdateText (CellContext context, double cellWidth)
+        {
+            string text = last_text = GetText (BoundObject);
             if (String.IsNullOrEmpty (text)) {
                 return;
             }
@@ -88,23 +108,22 @@
             }
             
             context.Layout.GetPixelSize (out text_width, out text_height);
-
-            context.Context.Rectangle (0, 0, cellWidth, cellHeight);
-            context.Context.Clip ();
-            context.Context.MoveTo (Spacing, ((int)cellHeight - text_height) / 2);
-            Cairo.Color color = context.Theme.Colors.GetWidgetColor (
-                context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, state);
-            color.A = (!context.Sensitive) ? 0.3 : opacity;
-            context.Context.Color = color;
-
-            PangoCairoHelper.ShowLayout (context.Context, context.Layout);
-            context.Context.ResetClip ();
+            is_ellipsized = context.Layout.IsEllipsized;
         }
         
         protected virtual string GetText (object obj)
         {
             return obj == null ? String.Empty : obj.ToString ();
         }
+
+        private bool is_ellipsized = false;
+        public bool IsEllipsized {
+            get { return is_ellipsized; }
+        }
+
+        public string Text {
+            get { return last_text; }
+        }
         
         protected int TextWidth {
             get { return text_width; }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/IInteractiveCell.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/IInteractiveCell.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/IInteractiveCell.cs	Mon Sep 29 16:03:41 2008
@@ -37,4 +37,4 @@
         bool MotionEvent (int x, int y, Gdk.EventMotion evnt);
         bool PointerLeaveEvent ();
     }
-}
+}
\ No newline at end of file

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs	Mon Sep 29 16:03:41 2008
@@ -26,6 +26,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
+
 namespace Hyena.Data.Gui
 {
     public partial class ListView<T> : ListViewBase, IListView<T>
@@ -35,6 +37,51 @@
             column_layout = new Pango.Layout (PangoContext);
             CanFocus = true;
             selection_proxy.Changed += delegate { InvalidateList (); };
+
+            // TODO this is working well except a crasher bug in Gtk+ or Gtk#
+            // See http://bugzilla.gnome.org/show_bug.cgi?id=524772
+            //HasTooltip = true;
+            //QueryTooltip += OnQueryTooltip;
         }
+
+        /*private void OnQueryTooltip (object o, Gtk.QueryTooltipArgs args)
+        {
+            if (cell_context == null || cell_context.Layout == null) {
+                return;
+            }
+            
+            if (!args.KeyboardTooltip) {
+                ColumnCellText cell;
+                Column column;
+                int row_index;
+                
+                if (GetEventCell<ColumnCellText> (args.X, args.Y, out cell, out column, out row_index)) {
+                    CachedColumn cached_column = GetCachedColumnForColumn (column);
+                    cell.UpdateText (cell_context, cached_column.Width);
+                    if (cell.IsEllipsized) {
+                        Gdk.Rectangle rect = new Gdk.Rectangle ();
+                        rect.X = list_interaction_alloc.X + cached_column.X1;
+
+                        // get the y of the event in list coords
+                        rect.Y = args.Y - list_interaction_alloc.Y;
+
+                        // get the top of the cell pointed to by list_y
+                        rect.Y -= VadjustmentValue % RowHeight;
+                        rect.Y -= rect.Y % RowHeight;
+
+                        // convert back to widget coords
+                        rect.Y += list_interaction_alloc.Y;
+
+                        rect.Width = cached_column.Width; // TODO is this right even if the list is wide enough to scroll horizontally?
+                        rect.Height = RowHeight; // TODO not right - could be smaller if at the top/bottom and only partially showing
+                        
+                        //System.Console.WriteLine ("Got ellipsized column text: {0} at {1};  event was at {3}, {4}", cell.Text, rect, rect.Y, args.X, args.Y);
+                        args.Tooltip.Markup = GLib.Markup.EscapeText (cell.Text);
+                        args.Tooltip.TipArea = rect;
+                        args.RetVal = true;
+                    }
+                }
+            }
+        }*/
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	Mon Sep 29 16:03:41 2008
@@ -247,18 +247,15 @@
                     icell_area.Width, icell_area.Height);
             }
         }
-        
+
         private bool ProxyEventToCell (Gdk.Event evnt, bool press, out IInteractiveCell icell, out Gdk.Rectangle icell_area)
         {
             icell = null;
             icell_area = Gdk.Rectangle.Zero;
-            
-            if (Model == null) {
-                return false;
-            }
-               
-            int evnt_x;
-            int evnt_y;
+
+            int evnt_x, evnt_y;
+            int x, y, row_index;
+            x = y = row_index = 0;
             
             Gdk.EventButton evnt_button = evnt as Gdk.EventButton;
             Gdk.EventMotion evnt_motion = evnt as Gdk.EventMotion;
@@ -274,47 +271,67 @@
                 icell = last_icell;
                 return false;
             }
-            
-            int y = evnt_y - list_interaction_alloc.Y;
-            int x = evnt_x - list_interaction_alloc.X;
-            
-            int row_index = GetRowAtY (y);
+
+            Column column;
+            if (!GetEventCell<IInteractiveCell> (evnt_x, evnt_y, out icell, out column, out row_index)) {
+                return false;
+            }
+
+            x = evnt_x - list_interaction_alloc.X;
+            y = evnt_y - list_interaction_alloc.Y;
+
+            // Turn the view-absolute coordinates into cell-relative coordinates
+            CachedColumn cached_column = GetCachedColumnForColumn (column);
+            x -= cached_column.X1;
+            int page_offset = VadjustmentValue % RowHeight;
+            y = (y + page_offset) % RowHeight;
+
+            icell_area.X = cached_column.X1 + Allocation.X;
+            icell_area.Y = (int)GetYAtRow (row_index) + list_interaction_alloc.Y + Allocation.Y;
+            icell_area.Width = cached_column.Width;
+            icell_area.Height = RowHeight;
+
+            // Send the cell a synthesized input event
+            if (evnt_motion != null) {
+                return icell.MotionEvent (x, y, evnt_motion);
+            } else {
+                return icell.ButtonEvent (x, y, press, evnt_button);
+            }
+        }
+        
+        private bool GetEventCell<T> (int x, int y, out T icell, out Column column, out int row_index) where T : class
+        {
+            icell = null;
+            column = null;
+            row_index = 0;
+
+            if (Model == null) {
+                return false;
+            }
+
+            x -= list_interaction_alloc.X;
+            y -= list_interaction_alloc.Y;
+
+            row_index = GetRowAtY (y);
             if (row_index < 0 || row_index >= Model.Count) {
                 return false;
             }
             
-            Column column = GetColumnAt (x);
+            column = GetColumnAt (x);
             if (column == null) {
                 return false;
             }
             
-            CachedColumn cached_column = GetCachedColumnForColumn (column);
-            
             ColumnCell cell = column.GetCell (0);
-            icell = cell as IInteractiveCell;
-            
+            icell = cell as T;
             if (icell == null) {
                 return false;
             }
             
-            // Turn the view-absolute coordinates into cell-relative coordinates
-            x -= cached_column.X1;
-            int page_offset = VadjustmentValue % RowHeight;
-            y = (y + page_offset) % RowHeight;
-            
-            // Bind the row to the cell and then send it a synthesized input event
+            // Bind the row to the cell
             cell.BindListItem (model[row_index]);
-            
-            bool redraw = (evnt_motion != null)
-                ? icell.MotionEvent (x, y, evnt_motion) : icell.ButtonEvent (x, y, press, evnt_button);
-            
-            icell_area.X = cached_column.X1 + Allocation.X;
-            icell_area.Y = (int)GetYAtRow (row_index) + list_interaction_alloc.Y + Allocation.Y;
-            icell_area.Width = cached_column.Width;
-            icell_area.Height = RowHeight;
-            
-            return redraw;
-        }   
+            return true;
+        }
         
 #endregion
         
@@ -680,7 +697,7 @@
             double y = (double)RowHeight * row;
             return y;
         }
-          
+
         private void FocusRow (int index)
         {
             Selection.FocusedIndex = index;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]