]> Pileus Git - ~andy/gtk/commitdiff
Handle focus [hv]adjustment correctly when the focus is located deeper
authorMatthias Clasen <maclas@gmx.de>
Wed, 11 Feb 2004 01:21:14 +0000 (01:21 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 11 Feb 2004 01:21:14 +0000 (01:21 +0000)
Wed Feb 11 02:23:39 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle
focus [hv]adjustment correctly when the focus is located deeper
down in the hierarchy.  (#133489)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcontainer.c

index 4b20e06d0329c7029c535616e59cf52651ac7dde..1399a74996e359fd13156b224858c52b3727a63b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Feb 11 02:23:39 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle
+       focus [hv]adjustment correctly when the focus is located deeper
+       down in the hierarchy.  (#133489)
+
 Wed Feb 11 02:06:38 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove 
@@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004  Owen Taylor  <otaylor@redhat.com>
        * tests/prop-editor.c (create_prop_editor): Free the title.
        (object_changed): Free the children list.
 
->>>>>>> 1.4914
 Tue Feb 10 01:58:55 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): 
index 4b20e06d0329c7029c535616e59cf52651ac7dde..1399a74996e359fd13156b224858c52b3727a63b 100644 (file)
@@ -1,3 +1,9 @@
+Wed Feb 11 02:23:39 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle
+       focus [hv]adjustment correctly when the focus is located deeper
+       down in the hierarchy.  (#133489)
+
 Wed Feb 11 02:06:38 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove 
@@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004  Owen Taylor  <otaylor@redhat.com>
        * tests/prop-editor.c (create_prop_editor): Free the title.
        (object_changed): Free the children list.
 
->>>>>>> 1.4914
 Tue Feb 10 01:58:55 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): 
index 4b20e06d0329c7029c535616e59cf52651ac7dde..1399a74996e359fd13156b224858c52b3727a63b 100644 (file)
@@ -1,3 +1,9 @@
+Wed Feb 11 02:23:39 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle
+       focus [hv]adjustment correctly when the focus is located deeper
+       down in the hierarchy.  (#133489)
+
 Wed Feb 11 02:06:38 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove 
@@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004  Owen Taylor  <otaylor@redhat.com>
        * tests/prop-editor.c (create_prop_editor): Free the title.
        (object_changed): Free the children list.
 
->>>>>>> 1.4914
 Tue Feb 10 01:58:55 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): 
index 4b20e06d0329c7029c535616e59cf52651ac7dde..1399a74996e359fd13156b224858c52b3727a63b 100644 (file)
@@ -1,3 +1,9 @@
+Wed Feb 11 02:23:39 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle
+       focus [hv]adjustment correctly when the focus is located deeper
+       down in the hierarchy.  (#133489)
+
 Wed Feb 11 02:06:38 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove 
@@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004  Owen Taylor  <otaylor@redhat.com>
        * tests/prop-editor.c (create_prop_editor): Free the title.
        (object_changed): Free the children list.
 
->>>>>>> 1.4914
 Tue Feb 10 01:58:55 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): 
index 4b20e06d0329c7029c535616e59cf52651ac7dde..1399a74996e359fd13156b224858c52b3727a63b 100644 (file)
@@ -1,3 +1,9 @@
+Wed Feb 11 02:23:39 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle
+       focus [hv]adjustment correctly when the focus is located deeper
+       down in the hierarchy.  (#133489)
+
 Wed Feb 11 02:06:38 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove 
@@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004  Owen Taylor  <otaylor@redhat.com>
        * tests/prop-editor.c (create_prop_editor): Free the title.
        (object_changed): Free the children list.
 
->>>>>>> 1.4914
 Tue Feb 10 01:58:55 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): 
index 77f18568f4b6650abbfeb9f21dd1c6b74a54f83e..b5f1049f0e07187106e4e44dcf702f4aca62033e 100644 (file)
@@ -1459,8 +1459,7 @@ gtk_container_real_set_focus_child (GtkContainer     *container,
                                    GtkWidget        *child)
 {
   g_return_if_fail (GTK_IS_CONTAINER (container));
-  if (child)
-    g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
 
   if (child != container->focus_child)
     {
@@ -1476,21 +1475,35 @@ gtk_container_real_set_focus_child (GtkContainer     *container,
    */
   if (container->focus_child)
     {
-      GtkAdjustment *adjustment;
-      
-      adjustment = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id);
-      if (adjustment)
-       gtk_adjustment_clamp_page (adjustment,
-                                  container->focus_child->allocation.y,
-                                  (container->focus_child->allocation.y +
-                                   container->focus_child->allocation.height));
-
-      adjustment = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id);
-      if (adjustment)
-       gtk_adjustment_clamp_page (adjustment,
-                                  container->focus_child->allocation.x,
-                                  (container->focus_child->allocation.x +
-                                   container->focus_child->allocation.width));
+      GtkAdjustment *hadj;
+      GtkAdjustment *vadj;
+      GtkWidget *focus_child;
+      gint x, y;
+
+      hadj = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id);   
+      vadj = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id);
+      if (hadj || vadj) 
+       {
+
+         focus_child = container->focus_child;
+         while (GTK_IS_CONTAINER (focus_child) && 
+                GTK_CONTAINER (focus_child)->focus_child)
+           {
+             focus_child = GTK_CONTAINER (focus_child)->focus_child;
+           }
+         
+         gtk_widget_translate_coordinates (focus_child, container->focus_child, 
+                                           0, 0, &x, &y);
+
+          x += container->focus_child->allocation.x;
+          y += container->focus_child->allocation.y;
+         
+         if (vadj)
+           gtk_adjustment_clamp_page (vadj, y, y + focus_child->allocation.height);
+         
+         if (hadj)
+           gtk_adjustment_clamp_page (hadj, x, x + focus_child->allocation.width);
+       }
     }
 }