summaryrefslogtreecommitdiff
path: root/packages/gtk+/gtk+-2.6.10/gtk.keynav.gtkiconview.patch
blob: 6ac9629767f9bad01221bb0f1eb7a9e373fda164 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
--- /data/zzz/gtk-2.6/gtk+-2.6.10/gtk/gtkiconview.c	2005-08-18 22:10:58.000000000 +0800
+++ gtk/gtkiconview.c	2006-05-31 18:12:34.423427466 +0800
@@ -2678,10 +2678,73 @@ find_item (GtkIconView     *icon_view,
 
   /* FIXME: this could be more efficient 
    */
-  row = current->row + row_ofs;
-  col = current->col + col_ofs;
+  int columns = (icon_view->priv->width - icon_view->priv->margin * 2 + icon_view->priv->column_spacing) / (icon_view->priv->column_spacing + current->width);
+  int rows = g_list_length (icon_view->priv->items) / columns;
+  if (g_list_length (icon_view->priv->items) % columns > 0)	
+    rows++;
 
-  for (items = icon_view->priv->items; items; items = items->next)
+  items = g_list_last(icon_view->priv->items);
+  item = items->data;  
+  if (col_ofs == 1) //right is pressed
+  {
+    if (current->col == item->col && current->row == (rows - 1)) //the current item is the last one, wrap to the first item
+    {
+      row = 0;
+      col = 0;
+    }
+    else if (current->col == (columns - 1)) //the current item is the rightmost one
+    {
+      row = current->row + row_ofs + 1;
+      col = 0;
+    }
+    else 
+    {
+      row = current->row + row_ofs;
+      col = current->col + col_ofs;      
+    }
+  }
+  else if (col_ofs == -1) //left is pressed
+  {
+    if (current->col == 0) //the current item is the leftmost one
+    {
+      if (current->row == 0) //the current item is the first one, wrap to the last item
+      {
+        row = rows - 1;
+        col = item->col;
+      }
+      else
+      {
+        row = current->row + row_ofs - 1;
+        col = columns - 1;
+      }
+    }
+    else
+    {
+      row = current->row + row_ofs;
+      col = current->col + col_ofs;
+    }
+  }
+  else if (row_ofs == 1) //down is pressed
+  {
+    if (current->row == (rows - 2) && item->col < current->col)// at the second last row
+    {
+      row = current->row + row_ofs;
+      col = 0;
+    }
+    else
+    {
+      row = current->row + row_ofs;
+      col = current->col + col_ofs;
+    }
+  }
+  else //up is pressed
+  {
+    row = current->row + row_ofs;
+    col = current->col + col_ofs;
+  }
+
+  g_message ("row:%d, col:%d", row, col);
+   for (items = icon_view->priv->items; items; items = items->next)
     {
       item = items->data;
       if (item->row == row && item->col == col)
@@ -2819,8 +2882,10 @@ gtk_icon_view_move_cursor_up_down (GtkIc
 		      count, 0);
 
   if (!item)
+  {
+    gtk_widget_child_focus (gtk_widget_get_toplevel (GTK_WIDGET(icon_view)), count > 0 ? GTK_DIR_TAB_FORWARD : GTK_DIR_TAB_BACKWARD);
     return;
-
+  }
   if (icon_view->priv->ctrl_pressed ||
       !icon_view->priv->shift_pressed ||
       !icon_view->priv->anchor_item ||