Fix for NB#87160
authorJose Dapena Paz <jdapena@igalia.com>
Fri, 1 Aug 2008 15:54:02 +0000 (15:54 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Fri, 1 Aug 2008 15:54:02 +0000 (15:54 +0000)
* src/widgets/modest-header-view.c:
  Removed code to rescroll to selected cells on focus in.
* src/maemo/modest-main-window.c:
  Added the equivalent code to rescroll to selected cells, but not on
  focus in always, but on focus in through keyboard navigation.

pmo-trunk-r5247

src/maemo/modest-main-window.c
src/widgets/modest-header-view.c

index 201130e..86a6570 100644 (file)
@@ -1745,8 +1745,45 @@ on_inner_widgets_key_pressed (GtkWidget *widget,
                                }
                        }
                }
-       } else if (MODEST_IS_FOLDER_VIEW (widget) && event->keyval == GDK_Right)
+       } else if (MODEST_IS_FOLDER_VIEW (widget) && (event->keyval == GDK_Right || event->keyval == GDK_Left)) {
+#if GTK_CHECK_VERSION(2, 8, 0) /* TODO: gtk_tree_view_get_visible_range() is only available in GTK+ 2.8 */
+               GtkTreePath *selected_path = NULL;
+               GtkTreePath *start_path = NULL;
+               GtkTreePath *end_path = NULL;
+               GList *selected;
+               GtkTreeSelection *selection;
+
+               selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->header_view));
+               selected = gtk_tree_selection_get_selected_rows (selection, NULL);
+               if (selected != NULL) {
+                       selected_path = (GtkTreePath *) selected->data;
+                       if (gtk_tree_view_get_visible_range (GTK_TREE_VIEW (priv->header_view),
+                                                            &start_path,
+                                                            &end_path)) {
+                               
+                               if ((gtk_tree_path_compare (start_path, selected_path) != -1) ||
+                                   (gtk_tree_path_compare (end_path, selected_path) != 1)) {
+                                       
+                                       /* Scroll to first path */
+                                       gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->header_view),
+                                                                     selected_path,
+                                                                     NULL,
+                                                                     TRUE,
+                                                                     0.5,
+                                                                     0.0);
+                               }
+                       }
+                       if (start_path)
+                               gtk_tree_path_free (start_path);
+                       if (end_path)
+                               gtk_tree_path_free (end_path);
+                       g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
+                       g_list_free (selected);
+               }
+#endif /* GTK_CHECK_VERSION */
+                       /* fix scroll */
                gtk_widget_grab_focus (GTK_WIDGET (priv->header_view));
+       }
 
        return FALSE;
 }
index 2d3096d..239d3dd 100644 (file)
@@ -1767,33 +1767,6 @@ on_focus_in (GtkWidget     *self,
        if (selected == NULL) return FALSE;
        selected_path = (GtkTreePath *) selected->data;
 
-       /* Check if we need to scroll */
-       #if GTK_CHECK_VERSION(2, 8, 0) /* TODO: gtk_tree_view_get_visible_range() is only available in GTK+ 2.8 */
-       GtkTreePath *start_path = NULL;
-       GtkTreePath *end_path = NULL;
-       if (gtk_tree_view_get_visible_range (GTK_TREE_VIEW (self),
-                                            &start_path,
-                                            &end_path)) {
-
-               if ((gtk_tree_path_compare (start_path, selected_path) != -1) ||
-                   (gtk_tree_path_compare (end_path, selected_path) != 1)) {
-
-                       /* Scroll to first path */
-                       gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (self),
-                                                     selected_path,
-                                                     NULL,
-                                                     TRUE,
-                                                     0.5,
-                                                     0.0);
-               }
-       }
-       if (start_path)
-               gtk_tree_path_free (start_path);
-       if (end_path)
-               gtk_tree_path_free (end_path);
-
-       #endif /* GTK_CHECK_VERSION */
-
        /* Frees */     
        g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
        g_list_free (selected);