[gtk+] listbox: Scroll headers on screen
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] listbox: Scroll headers on screen
- Date: Sun, 13 Jul 2014 17:01:01 +0000 (UTC)
commit a2ac9e1baa85fbbf5c80bd5388a31301072d5f61
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 13 12:31:28 2014 -0400
listbox: Scroll headers on screen
The listbox code relies on the container focus adjustment handling
to scroll the cursor row on screen. But GtkContainer has no idea
about row headers, so ensure that we scroll the header on screen too.
gtk/gtklistbox.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 2958a3a..d3afac4 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -1327,10 +1327,31 @@ gtk_list_box_add_move_binding (GtkBindingSet *binding_set,
}
static void
+ensure_row_visible (GtkListBox *box,
+ GtkListBoxRow *row)
+{
+ GtkListBoxPrivate *priv = BOX_PRIV (box);
+ GtkWidget *header;
+ GtkWidget *widget;
+ GtkAllocation allocation;
+
+ /* If the row has a header, we want to ensure that it is visible as well. */
+ header = ROW_PRIV (row)->header;
+ if (GTK_IS_WIDGET (header) && gtk_widget_is_drawable (header))
+ widget = header;
+ else
+ widget = GTK_WIDGET (row);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_adjustment_clamp_page (priv->adjustment, allocation.y, allocation.y + allocation.height);
+}
+
+static void
gtk_list_box_update_cursor (GtkListBox *box,
GtkListBoxRow *row)
{
BOX_PRIV (box)->cursor_row = row;
+ ensure_row_visible (box, row);
gtk_widget_grab_focus (GTK_WIDGET (row));
gtk_widget_queue_draw (GTK_WIDGET (row));
_gtk_list_box_accessible_update_cursor (box, row);
@@ -2682,7 +2703,8 @@ gtk_list_box_move_cursor (GtkListBox *box,
case GTK_MOVEMENT_DISPLAY_LINES:
if (priv->cursor_row != NULL)
{
- int i = count;
+ gint i = count;
+
iter = ROW_PRIV (priv->cursor_row)->iter;
while (i < 0 && iter != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]