[maemo-commits] [maemo-commits] r9087 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Sun Jan 14 23:41:04 EET 2007
Author: kris
Date: 2007-01-14 23:41:02 +0200 (Sun, 14 Jan 2007)
New Revision: 9087

Modified:
   projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog
   projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeselection.c
   projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeview.c
Log:
2007-01-14  Kristian Rietveld  <kris at imendio.com>

	* gtk/gtktreeselection.c (tree_column_is_sensitive),
	(_gtk_tree_selection_row_is_selectable): patched since
	selectable rows are not allowed to be insensitive.

	* gtk/gtktreeview.c (gtk_tree_view_focus_to_cursor): make sure
	we put the cursor on a row which can be selected,
	(gtk_tree_view_move_cursor_up_down),
	(gtk_tree_view_move_cursor_page_up_down): patched to only move
	the cursor to selectable rows.



Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog
===================================================================
--- projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog	2007-01-12 15:04:08 UTC (rev 9086)
+++ projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog	2007-01-14 21:41:02 UTC (rev 9087)
@@ -1,3 +1,15 @@
+2007-01-14  Kristian Rietveld  <kris at imendio.com>
+
+	* gtk/gtktreeselection.c (tree_column_is_sensitive),
+	(_gtk_tree_selection_row_is_selectable): patched since
+	selectable rows are not allowed to be insensitive.
+
+	* gtk/gtktreeview.c (gtk_tree_view_focus_to_cursor): make sure
+	we put the cursor on a row which can be selected,
+	(gtk_tree_view_move_cursor_up_down),
+	(gtk_tree_view_move_cursor_page_up_down): patched to only move
+	the cursor to selectable rows.
+
 2007-01-12  Michael Natterer  <mitch at imendio.com>
 
 	* gtk/gtkentry.c: port over "icon-width" style property.

Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeselection.c
===================================================================
--- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeselection.c	2007-01-12 15:04:08 UTC (rev 9086)
+++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeselection.c	2007-01-14 21:41:02 UTC (rev 9087)
@@ -1231,11 +1231,48 @@
     g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
 }
 
+/* MEAMO START */
+static gboolean
+tree_column_is_sensitive (GtkTreeViewColumn *column,
+			  GtkTreeModel      *model,
+			  GtkTreeIter       *iter)
+{
+  GList *cells, *list;
+  gboolean sensitive;
+  gboolean visible;
+
+  gtk_tree_view_column_cell_set_cell_data (column, model,
+					   iter, FALSE, FALSE);
+
+  cells = gtk_tree_view_column_get_cell_renderers (column);
+
+  list = cells;
+  while (list)
+    {
+      g_object_get (list->data,
+		    "sensitive", &sensitive,
+		    "visible", &visible,
+		    NULL);
+      
+      if (visible && sensitive)
+	break;
+
+      list = list->next;
+    }
+  g_list_free (cells);
+
+  return sensitive;
+}
+/* MAEMO END */
+
 gboolean
 _gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
 				       GtkRBNode        *node,
 				       GtkTreePath      *path)
 {
+  /* MAEMO START */
+  GList *list;
+  /* MAEMO END */
   GtkTreeIter iter;
   gboolean sensitive = FALSE;
 
@@ -1251,6 +1288,21 @@
 	return FALSE;
     }
 
+  /* MAEMO START */
+  for (list = selection->tree_view->priv->columns; list && !sensitive; list = list->next)
+    {
+      GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data);
+
+      if (!column->visible)
+	continue;
+
+      sensitive = tree_column_is_sensitive (column, selection->tree_view->priv->model, &iter);
+    }
+
+  if (!sensitive)
+    return FALSE;
+  /* MAEMO END */
+
   if (selection->user_func)
     return (*selection->user_func) (selection, selection->tree_view->priv->model, path,
 				    GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED),

Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeview.c
===================================================================
--- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeview.c	2007-01-12 15:04:08 UTC (rev 9086)
+++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtktreeview.c	2007-01-14 21:41:02 UTC (rev 9087)
@@ -9470,8 +9470,36 @@
 	  g_list_free (selected_rows);
         }
       else
-	cursor_path = gtk_tree_path_new_first ();
+	/* MAEMO START */
+        {
+	  GtkRBTree *tree;
+	  GtkRBNode *node;
 
+	  /* Make sure the row we are about to place the cursor on
+	   * is sensitive.
+	   */
+	  cursor_path = gtk_tree_path_new_first ();
+	  _gtk_tree_view_find_node (tree_view, cursor_path, &tree, &node);
+
+	  while (node &&
+	         !_gtk_tree_selection_row_is_selectable (tree_view->priv->selection,
+							 node, cursor_path))
+	    {
+	      _gtk_rbtree_next_full (tree, node, &tree, &node);
+
+	      if (node)
+	        {
+		  if (cursor_path)
+		    gtk_tree_path_free (cursor_path);
+
+		  cursor_path = _gtk_tree_view_find_path (tree_view, tree, node);
+		}
+	    }
+
+	  /* FIXME: this fails for views without sensitive items ... */
+	}
+        /* MAEMO END */
+
       gtk_tree_row_reference_free (tree_view->priv->cursor);
       tree_view->priv->cursor = NULL;
 
@@ -9542,6 +9570,40 @@
 			       &new_cursor_tree, &new_cursor_node);
     }
 
+  /* MAEMO START */
+  if (new_cursor_node)
+    cursor_path = _gtk_tree_view_find_path (tree_view,
+					    new_cursor_tree, new_cursor_node);
+  else
+    cursor_path = NULL;
+
+  while (new_cursor_node &&
+         !_gtk_tree_selection_row_is_selectable (tree_view->priv->selection,
+						 new_cursor_node,
+						 cursor_path))
+    {
+      if (count == -1)
+	_gtk_rbtree_prev_full (new_cursor_tree, new_cursor_node,
+			       &new_cursor_tree, &new_cursor_node);
+      else
+	_gtk_rbtree_next_full (new_cursor_tree, new_cursor_node,
+			       &new_cursor_tree, &new_cursor_node);
+
+      if (new_cursor_node)
+        {
+	  if (cursor_path)
+	    gtk_tree_path_free (cursor_path);
+
+	  cursor_path = _gtk_tree_view_find_path (tree_view,
+				 		  new_cursor_tree,
+						  new_cursor_node);
+	}
+    }
+
+  if (cursor_path)
+    gtk_tree_path_free (cursor_path);
+  /* MAEMO END */
+
   /*
    * If the list has only one item and multi-selection is set then select
    * the row.
@@ -9591,6 +9653,10 @@
   gint y;
   gint window_y;
   gint vertical_separator;
+  /* MAEMO START */
+  GtkRBTree *start_cursor_tree = NULL;
+  GtkRBNode *start_cursor_node = NULL;
+  /* MAEMO END */
 
   if (! GTK_WIDGET_HAS_FOCUS (tree_view))
     return;
@@ -9622,7 +9688,73 @@
 
   y -= _gtk_rbtree_find_offset (tree_view->priv->tree, y, &cursor_tree, &cursor_node);
   cursor_path = _gtk_tree_view_find_path (tree_view, cursor_tree, cursor_node);
-  g_return_if_fail (cursor_path != NULL);
+
+  /* MAEMO START */
+  start_cursor_tree = cursor_tree;
+  start_cursor_node = cursor_node;
+
+  while (cursor_node &&
+         !_gtk_tree_selection_row_is_selectable (tree_view->priv->selection,
+						 cursor_node,
+						 cursor_path))
+    {
+      if (count == -1)
+	_gtk_rbtree_prev_full (cursor_tree, cursor_node,
+			       &cursor_tree, &cursor_node);
+      else
+	_gtk_rbtree_next_full (cursor_tree, cursor_node,
+			       &cursor_tree, &cursor_node);
+
+      if (cursor_path)
+	gtk_tree_path_free (cursor_path);
+
+      if (cursor_node)
+	cursor_path = _gtk_tree_view_find_path (tree_view,
+						cursor_tree,
+						cursor_node);
+      else
+	cursor_path = NULL;
+    }
+
+  if (cursor_path == NULL)
+    {
+      /* It looks like we reached the end of the view without finding
+       * a sensitive row.  We will step backwards to find the last
+       * sensitive row.
+       */
+      cursor_tree = start_cursor_tree;
+      cursor_node = start_cursor_node;
+      cursor_path = _gtk_tree_view_find_path (tree_view, cursor_tree, cursor_node);
+
+      while (cursor_node &&
+	     !_gtk_tree_selection_row_is_selectable (tree_view->priv->selection,
+						     cursor_node,
+						     cursor_path))
+        {
+	  if (count == -1)
+	    _gtk_rbtree_next_full (cursor_tree, cursor_node,
+				   &cursor_tree, &cursor_node);
+	  else
+	    _gtk_rbtree_prev_full (cursor_tree, cursor_node,
+				   &cursor_tree, &cursor_node);
+
+	  if (cursor_path)
+	    gtk_tree_path_free (cursor_path);
+
+	  if (cursor_node)
+	    cursor_path = _gtk_tree_view_find_path (tree_view,
+						    cursor_tree,
+						    cursor_node);
+	  else
+	    cursor_path = NULL;
+	}
+    }
+
+  /* update y */
+  y = _gtk_rbtree_node_find_offset (cursor_tree, cursor_node);
+
+  /* MAEMO END */
+
   gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, FALSE);
   gtk_tree_path_free (cursor_path);
 


More information about the maemo-commits mailing list