banshee r3262 - in trunk/banshee: . src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView



Author: gburt
Date: Mon Feb 18 00:41:32 2008
New Revision: 3262
URL: http://svn.gnome.org/viewvc/banshee?rev=3262&view=rev

Log:
2008-02-17  Gabriel Burt  <gabriel burt gmail com>

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
	Avoid hitting the model/database when clicking where there is no row.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs

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 Feb 18 00:41:32 2008
@@ -233,12 +233,16 @@
             GrabFocus ();
             
             int row_index = GetRowAtY ((int)press.Y);
+
+            if (row_index >= Model.Count) {
+                return true;
+            }
             
             if (press.Button == 1 && press.Type != Gdk.EventType.TwoButtonPress && 
                 (press.State & Gdk.ModifierType.ControlMask) == 0 && Selection.Contains (row_index)) {
                 return true;
             }
-            
+
             object item = model[row_index];
             if (item == null) {
                 return true;
@@ -320,6 +324,11 @@
                 GrabFocus ();
                 
                 int row_index = GetRowAtY ((int)evnt.Y);
+
+                if (row_index >= Model.Count) {
+                    return true;
+                }
+
                 object item = model[row_index];
                 if (item == null) {
                     return true;
@@ -412,7 +421,7 @@
             }
         }
         
-        private int GetRowAtY (int y)
+        protected int GetRowAtY (int y)
         {
             int page_offset = (int)vadjustment.Value % RowHeight;
             int first_row = (int)vadjustment.Value / RowHeight;
@@ -421,7 +430,7 @@
             return first_row + row_offset;
         }
 
-        private double GetYAtRow (int row)
+        protected double GetYAtRow (int row)
         {
             double y = (double) RowHeight * row;
             return y;



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