GtkXPaned: Convert expose-event signal to draw signal
[pspp] / lib / gtk-contrib / gtkxpaned.c
index 5c861eeea38e08a7160c0ad7fbe53e022d248476..f653f93c92346a7ddae2df6743f8045577d63948 100644 (file)
@@ -1,34 +1,34 @@
 /*******************************************************************************
-**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 
-**      10        20        30        40        50        60        70        80
-**
-**  library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+
-**  Copyright (C) 2012 Free Software Foundation, Inc.
-**  Copyright (C) 2005-2006 Mirco "MacSlow" Müller <macslow@bangang.de>
-**
-**  This library is free software; you can redistribute it and/or
-**  modify it under the terms of the GNU Lesser General Public
-**  License as published by the Free Software Foundation; either
-**  version 2.1 of the License, or (at your option) any later version.
-**
-**  This library is distributed in the hope that it will be useful,
-**  but WITHOUT ANY WARRANTY; without even the implied warranty of
-**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-**  Lesser General Public License for more details.
-**
-**  You should have received a copy of the GNU Lesser General Public
-**  License along with this library; if not, write to the Free Software
-**  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**  GtkXPaned is based on GtkPaned which was done by...
-**
-**  "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald"
-**
-**  and later modified by...
-**
-**  "the GTK+ Team and others 1997-2000"
-**
-*******************************************************************************/
+ **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 
+ **      10        20        30        40        50        60        70        80
+ **
+ **  library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+
+ **  Copyright (C) 2012 Free Software Foundation, Inc.
+ **  Copyright (C) 2005-2006 Mirco "MacSlow" Müller <macslow@bangang.de>
+ **
+ **  This library is free software; you can redistribute it and/or
+ **  modify it under the terms of the GNU Lesser General Public
+ **  License as published by the Free Software Foundation; either
+ **  version 2.1 of the License, or (at your option) any later version.
+ **
+ **  This library is distributed in the hope that it will be useful,
+ **  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ **  Lesser General Public License for more details.
+ **
+ **  You should have received a copy of the GNU Lesser General Public
+ **  License along with this library; if not, write to the Free Software
+ **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ **
+ **  GtkXPaned is based on GtkPaned which was done by...
+ **
+ **  "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald"
+ **
+ **  and later modified by...
+ **
+ **  "the GTK+ Team and others 1997-2000"
+ **
+ *******************************************************************************/
 
 #include <config.h>
 #include "gtkxpaned.h"
 #include <gtk/gtk.h>
 #include <ui/gui/psppire-marshal.h>
 #include <gdk/gdkkeysyms.h>
-
+#include <gdk/gdkkeysyms-compat.h>
 
 enum WidgetProperties
-{
-  PROP_0,
-  PROP_X_POSITION,
-  PROP_Y_POSITION,
-  PROP_POSITION_SET,
-  PROP_MIN_X_POSITION,
-  PROP_MIN_Y_POSITION,
-  PROP_MAX_X_POSITION,
-  PROP_MAX_Y_POSITION
-};
+  {
+    PROP_0,
+    PROP_X_POSITION,
+    PROP_Y_POSITION,
+    PROP_POSITION_SET,
+    PROP_MIN_X_POSITION,
+    PROP_MIN_Y_POSITION,
+    PROP_MAX_X_POSITION,
+    PROP_MAX_Y_POSITION
+  };
 
 enum ChildProperties
-{
-  CHILD_PROP_0,
-  CHILD_PROP_RESIZE,
-  CHILD_PROP_SHRINK
-};
+  {
+    CHILD_PROP_0,
+    CHILD_PROP_RESIZE,
+    CHILD_PROP_SHRINK
+  };
 
 enum WidgetSignals
-{
-  CYCLE_CHILD_FOCUS,
-  TOGGLE_HANDLE_FOCUS,
-  MOVE_HANDLE,
-  CYCLE_HANDLE_FOCUS,
-  ACCEPT_POSITION,
-  CANCEL_POSITION,
-  LAST_SIGNAL
-};
+  {
+    CYCLE_CHILD_FOCUS,
+    TOGGLE_HANDLE_FOCUS,
+    MOVE_HANDLE,
+    CYCLE_HANDLE_FOCUS,
+    ACCEPT_POSITION,
+    CANCEL_POSITION,
+    LAST_SIGNAL
+  };
 
 static void gtk_xpaned_class_init (GtkXPanedClass * klass);
 
@@ -109,8 +109,8 @@ static void gtk_xpaned_map (GtkWidget * widget);
 
 static void gtk_xpaned_unmap (GtkWidget * widget);
 
-static gboolean gtk_xpaned_expose (GtkWidget * widget,
-                                   GdkEventExpose * event);
+static gboolean gtk_xpaned_draw (GtkWidget * widget,
+                                   cairo_t *ct);
 
 static gboolean gtk_xpaned_enter (GtkWidget * widget,
                                   GdkEventCrossing * event);
@@ -268,7 +268,7 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
   widget_class->unrealize = gtk_xpaned_unrealize;
   widget_class->map = gtk_xpaned_map;
   widget_class->unmap = gtk_xpaned_unmap;
-  widget_class->expose_event = gtk_xpaned_expose;
+  widget_class->draw = gtk_xpaned_draw;
   widget_class->focus = gtk_xpaned_focus;
   widget_class->enter_notify_event = gtk_xpaned_enter;
   widget_class->leave_notify_event = gtk_xpaned_leave;
@@ -332,14 +332,14 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
                                                              G_MAXINT,
                                                              3,
                                                              G_PARAM_READABLE));
-        /**
-       * GtkXPaned:min-x-position:
-       *
-       * The smallest possible value for the x-position property. This property is derived from the
-       * size and shrinkability of the widget's children.
-       *
-       * Since: 2.4
-       */
+  /**
+   * GtkXPaned:min-x-position:
+   *
+   * The smallest possible value for the x-position property. This property is derived from the
+   * size and shrinkability of the widget's children.
+   *
+   * Since: 2.4
+   */
   g_object_class_install_property (object_class,
                                    PROP_MIN_X_POSITION,
                                    g_param_spec_int ("min-x-position",
@@ -349,14 +349,14 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
                                                      G_MAXINT,
                                                      0, G_PARAM_READABLE));
 
-        /**
-       * GtkXPaned:min-y-position:
-       *
-       * The smallest possible value for the y-position property. This property is derived from the
-       * size and shrinkability of the widget's children.
-       *
-       * Since: 2.4
-       */
+  /**
+   * GtkXPaned:min-y-position:
+   *
+   * The smallest possible value for the y-position property. This property is derived from the
+   * size and shrinkability of the widget's children.
+   *
+   * Since: 2.4
+   */
   g_object_class_install_property (object_class,
                                    PROP_MIN_Y_POSITION,
                                    g_param_spec_int ("min-y-position",
@@ -366,14 +366,14 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
                                                      G_MAXINT,
                                                      0, G_PARAM_READABLE));
 
-        /**
-       * GtkPaned:max-x-position:
-       *
-       * The largest possible value for the x-position property. This property is derived from the
-       * size and shrinkability of the widget's children.
-       *
-       * Since: 2.4
-       */
+  /**
+   * GtkPaned:max-x-position:
+   *
+   * The largest possible value for the x-position property. This property is derived from the
+   * size and shrinkability of the widget's children.
+   *
+   * Since: 2.4
+   */
   g_object_class_install_property (object_class,
                                    PROP_MAX_X_POSITION,
                                    g_param_spec_int ("max-x-position",
@@ -384,14 +384,14 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
                                                      G_MAXINT,
                                                      G_PARAM_READABLE));
 
-        /**
-       * GtkPaned:max-y-position:
-       *
-       * The largest possible value for the y-position property. This property is derived from the
-       * size and shrinkability of the widget's children.
-       *
-       * Since: 2.4
-       */
+  /**
+   * GtkPaned:max-y-position:
+   *
+   * The largest possible value for the y-position property. This property is derived from the
+   * size and shrinkability of the widget's children.
+   *
+   * Since: 2.4
+   */
   g_object_class_install_property (object_class,
                                    PROP_MAX_Y_POSITION,
                                    g_param_spec_int ("max-y-position",
@@ -402,14 +402,14 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
                                                      G_MAXINT,
                                                      G_PARAM_READABLE));
 
-        /**
-       * GtkPaned:resize:
-       *
-       * The "resize" child property determines whether the child expands and 
-       * shrinks along with the paned widget.
-       
-       * Since: 2.4 
-       */
+  /**
+   * GtkPaned:resize:
+   *
+   * The "resize" child property determines whether the child expands and 
+   * shrinks along with the paned widget.
+   * 
+   * Since: 2.4 
+   */
   gtk_container_class_install_child_property (container_class,
                                               CHILD_PROP_RESIZE,
                                               g_param_spec_boolean ("resize",
@@ -418,14 +418,14 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
                                                                     TRUE,
                                                                     G_PARAM_READWRITE));
 
-        /**
-       * GtkPaned:shrink:
-       *
-       * The "shrink" child property determines whether the child can be made 
-       * smaller than its requisition.
-       
-       * Since: 2.4 
-       */
+  /**
+   * GtkPaned:shrink:
+   *
+   * The "shrink" child property determines whether the child can be made 
+   * smaller than its requisition.
+   * 
+   * Since: 2.4 
+   */
   gtk_container_class_install_child_property (container_class,
                                               CHILD_PROP_SHRINK,
                                               g_param_spec_boolean ("shrink",
@@ -596,7 +596,8 @@ gtk_xpaned_child_type (GtkContainer * container)
 static void
 gtk_xpaned_init (GtkXPaned * xpaned)
 {
-  GTK_WIDGET_SET_FLAGS (xpaned, GTK_NO_WINDOW | GTK_CAN_FOCUS);
+  gtk_widget_set_can_focus (GTK_WIDGET (xpaned), TRUE);
+  gtk_widget_set_has_window (GTK_WIDGET (xpaned), FALSE);
 
   xpaned->top_left_child = NULL;
   xpaned->top_right_child = NULL;
@@ -607,7 +608,6 @@ gtk_xpaned_init (GtkXPaned * xpaned)
   xpaned->handle_north = NULL;
   xpaned->handle_south = NULL;
   xpaned->handle_middle = NULL;
-  xpaned->xor_gc = NULL;
   xpaned->cursor_type_east = GDK_SB_V_DOUBLE_ARROW;
   xpaned->cursor_type_west = GDK_SB_V_DOUBLE_ARROW;
   xpaned->cursor_type_north = GDK_SB_H_DOUBLE_ARROW;
@@ -712,8 +712,8 @@ gtk_xpaned_size_request (GtkWidget * widget, GtkRequisition * requisition)
     }
 
   /* add 2 times the set border-width to the GtkXPaneds requisition */
-  requisition->width += GTK_CONTAINER (xpaned)->border_width * 2;
-  requisition->height += GTK_CONTAINER (xpaned)->border_width * 2;
+  requisition->width += gtk_container_get_border_width (GTK_CONTAINER (xpaned)) * 2;
+  requisition->height += gtk_container_get_border_width (GTK_CONTAINER (xpaned)) * 2;
 
   /* also add the handle "thickness" to GtkXPaneds width- and height-requisitions */
   if (xpaned->top_left_child
@@ -746,7 +746,7 @@ static void
 gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 {
   GtkXPaned *xpaned = GTK_XPANED (widget);
-  gint border_width = GTK_CONTAINER (xpaned)->border_width;
+  gint border_width = gtk_container_get_border_width (GTK_CONTAINER (xpaned));
   GtkAllocation top_left_child_allocation;
   GtkAllocation top_right_child_allocation;
   GtkAllocation bottom_left_child_allocation;
@@ -760,7 +760,7 @@ gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
   /* determine size of handle(s) */
   gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
 
-  widget->allocation = *allocation;
+  gtk_widget_set_allocation (widget, allocation);
 
   if (xpaned->top_left_child
       && gtk_widget_get_visible (xpaned->top_left_child)
@@ -792,34 +792,34 @@ gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 
       /* calculate the current positions and sizes of the handles */
       xpaned->handle_pos_east.x =
-        widget->allocation.x + border_width +
+        allocation->x + border_width +
         xpaned->top_left_child_size.width + handle_size;
       xpaned->handle_pos_east.y =
-        widget->allocation.y + border_width +
+        allocation->y + border_width +
         xpaned->top_left_child_size.height;
       xpaned->handle_pos_east.width =
-        widget->allocation.width - xpaned->top_left_child_size.width -
+        allocation->width - xpaned->top_left_child_size.width -
         2 * border_width - handle_size;
       xpaned->handle_pos_east.height = handle_size;
 
-      xpaned->handle_pos_west.x = widget->allocation.x + border_width;
+      xpaned->handle_pos_west.x = allocation->x + border_width;
       xpaned->handle_pos_west.y = xpaned->handle_pos_east.y;
       xpaned->handle_pos_west.width =
-        widget->allocation.width - xpaned->handle_pos_east.width -
+        allocation->width - xpaned->handle_pos_east.width -
         2 * border_width - handle_size;
       xpaned->handle_pos_west.height = handle_size;
 
       xpaned->handle_pos_north.x = xpaned->handle_pos_east.x - handle_size;
-      xpaned->handle_pos_north.y = widget->allocation.y + border_width;
+      xpaned->handle_pos_north.y = allocation->y + border_width;
       xpaned->handle_pos_north.width = handle_size;
       xpaned->handle_pos_north.height =
-        xpaned->handle_pos_east.y - widget->allocation.y - border_width;
+        xpaned->handle_pos_east.y - allocation->y - border_width;
 
       xpaned->handle_pos_south.x = xpaned->handle_pos_north.x;
       xpaned->handle_pos_south.y = xpaned->handle_pos_east.y + handle_size;
       xpaned->handle_pos_south.width = handle_size;
       xpaned->handle_pos_south.height =
-        widget->allocation.height - xpaned->handle_pos_north.height -
+        allocation->height - xpaned->handle_pos_north.height -
         2 * border_width - handle_size;
 
 
@@ -830,16 +830,16 @@ gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
       xpaned->handle_pos_middle.height = handle_size + CENTRUM;
 
       /* set allocation for top-left child */
-      top_left_child_allocation.x = widget->allocation.x + border_width;
-      top_left_child_allocation.y = widget->allocation.y + border_width;
+      top_left_child_allocation.x = allocation->x + border_width;
+      top_left_child_allocation.y = allocation->y + border_width;
       top_left_child_allocation.width = xpaned->handle_pos_west.width;
       top_left_child_allocation.height = xpaned->handle_pos_north.height;
 
       /* set allocation for top-right child */
       top_right_child_allocation.x =
-        widget->allocation.x + border_width + handle_size +
+        allocation->x + border_width + handle_size +
         top_left_child_allocation.width;
-      top_right_child_allocation.y = widget->allocation.y + border_width;
+      top_right_child_allocation.y = allocation->y + border_width;
       top_right_child_allocation.width = xpaned->handle_pos_east.width;
       top_right_child_allocation.height = xpaned->handle_pos_north.height;
 
@@ -1132,11 +1132,11 @@ gtk_xpaned_realize (GtkWidget * widget)
   gint attributes_mask_south;
   gint attributes_mask_middle;
 
-  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+  gtk_widget_set_realized (widget, TRUE);
   xpaned = GTK_XPANED (widget);
 
-  widget->window = gtk_widget_get_parent_window (widget);
-  g_object_ref (widget->window);
+  gtk_widget_set_window (widget, gtk_widget_get_parent_window (widget));
+  //  g_object_ref (widget->window);
 
   attributes_east.window_type = GDK_WINDOW_CHILD;
   attributes_west.window_type = GDK_WINDOW_CHILD;
@@ -1234,19 +1234,19 @@ gtk_xpaned_realize (GtkWidget * widget)
   attributes_mask_south = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
   attributes_mask_middle = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
 
-  xpaned->handle_east = gdk_window_new (widget->window,
+  xpaned->handle_east = gdk_window_new (gtk_widget_get_window (widget),
                                         &attributes_east,
                                         attributes_mask_east);
-  xpaned->handle_west = gdk_window_new (widget->window,
+  xpaned->handle_west = gdk_window_new (gtk_widget_get_window (widget),
                                         &attributes_west,
                                         attributes_mask_west);
-  xpaned->handle_north = gdk_window_new (widget->window,
+  xpaned->handle_north = gdk_window_new (gtk_widget_get_window (widget),
                                          &attributes_north,
                                          attributes_mask_north);
-  xpaned->handle_south = gdk_window_new (widget->window,
+  xpaned->handle_south = gdk_window_new (gtk_widget_get_window (widget),
                                          &attributes_south,
                                          attributes_mask_south);
-  xpaned->handle_middle = gdk_window_new (widget->window,
+  xpaned->handle_middle = gdk_window_new (gtk_widget_get_window (widget),
                                           &attributes_middle,
                                           attributes_mask_middle);
 
@@ -1262,7 +1262,12 @@ gtk_xpaned_realize (GtkWidget * widget)
   gdk_cursor_unref (attributes_south.cursor);
   gdk_cursor_unref (attributes_middle.cursor);
 
-  widget->style = gtk_style_attach (widget->style, widget->window);
+  {
+  GtkStyle *style = gtk_widget_get_style (widget);
+  style = gtk_style_attach (style, gtk_widget_get_window (widget));
+  gtk_widget_set_style (widget, style);
+  }
+  
 
   if (xpaned->top_left_child
       && gtk_widget_get_visible (xpaned->top_left_child)
@@ -1286,12 +1291,6 @@ gtk_xpaned_unrealize (GtkWidget * widget)
 {
   GtkXPaned *xpaned = GTK_XPANED (widget);
 
-  if (xpaned->xor_gc)
-    {
-      g_object_unref (xpaned->xor_gc);
-      xpaned->xor_gc = NULL;
-    }
-
   if (xpaned->handle_east)
     {
       gdk_window_set_user_data (xpaned->handle_east, NULL);
@@ -1367,7 +1366,7 @@ gtk_xpaned_unmap (GtkWidget * widget)
 }
 
 static gboolean
-gtk_xpaned_expose (GtkWidget * widget, GdkEventExpose * event)
+gtk_xpaned_draw (GtkWidget * widget, cairo_t *cr)
 {
   GtkXPaned *xpaned = GTK_XPANED (widget);
   gint handle_size;
@@ -1413,40 +1412,39 @@ gtk_xpaned_expose (GtkWidget * widget, GdkEventExpose * event)
         xpaned->handle_pos_north.height + handle_size +
         xpaned->handle_pos_south.height;
 
-      gtk_paint_handle (widget->style,
-                        widget->window,
+      gtk_paint_handle (gtk_widget_get_style (widget),
+                        cr,
                         state,
                         GTK_SHADOW_NONE,
-                        &horizontalClipArea,
                         widget,
                         "paned",
                         xpaned->handle_pos_east.x - handle_size - 256 / 2,
                         xpaned->handle_pos_west.y + 1,
                         256 + handle_size, handle_size - 2,
                         /*xpaned->handle_pos_west.x,
-                           xpaned->handle_pos_west.y + 1,
-                           xpaned->handle_pos_west.width + handle_size + xpaned->handle_pos_east.width,
-                           handle_size - 2, */
+                          xpaned->handle_pos_west.y + 1,
+                          xpaned->handle_pos_west.width + handle_size + xpaned->handle_pos_east.width,
+                          handle_size - 2, */
                         GTK_ORIENTATION_HORIZONTAL);
-      gtk_paint_handle (widget->style,
-                        widget->window,
+
+      gtk_paint_handle (gtk_widget_get_style (widget),
+                        cr,
                         state,
                         GTK_SHADOW_NONE,
-                        &verticalClipArea,
                         widget,
                         "paned",
                         xpaned->handle_pos_north.x + 1,
                         xpaned->handle_pos_south.y - handle_size - 256 / 2,
                         handle_size - 2, 256 + handle_size,
                         /*xpaned->handle_pos_north.x + 1,
-                           xpaned->handle_pos_north.y,
-                           handle_size - 2,
-                           xpaned->handle_pos_north.height + handle_size + xpaned->handle_pos_south.height, */
+                          xpaned->handle_pos_north.y,
+                          handle_size - 2,
+                          xpaned->handle_pos_north.height + handle_size + xpaned->handle_pos_south.height, */
                         GTK_ORIENTATION_VERTICAL);
     }
 
   /* Chain up to draw children */
-  GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+  GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
 
   return FALSE;
 }
@@ -1466,6 +1464,8 @@ update_drag (GtkXPaned * xpaned)
   GdkPoint pos;
   gint handle_size;
   GtkRequisition size;
+  GtkAllocation allocation;
+  gtk_widget_get_allocation (GTK_WIDGET (xpaned), &allocation);
 
   gtk_widget_get_pointer (GTK_WIDGET (xpaned), &pos.x, &pos.y);
 
@@ -1478,15 +1478,14 @@ update_drag (GtkXPaned * xpaned)
           gtk_widget_style_get (GTK_WIDGET (xpaned),
                                 "handle-size", &handle_size, NULL);
 
-          size.height =
-            GTK_WIDGET (xpaned)->allocation.height - pos.y - handle_size;
+          size.height = allocation.height - pos.y - handle_size;
         }
       else
         {
           size.height = pos.y;
         }
 
-      size.height -= GTK_CONTAINER (xpaned)->border_width;
+      size.height -= gtk_container_get_border_width (GTK_CONTAINER (xpaned));
 
       size.height =
         CLAMP (size.height, xpaned->min_position.y, xpaned->max_position.y);
@@ -1504,15 +1503,14 @@ update_drag (GtkXPaned * xpaned)
           gtk_widget_style_get (GTK_WIDGET (xpaned),
                                 "handle-size", &handle_size, NULL);
 
-          size.width =
-            GTK_WIDGET (xpaned)->allocation.width - pos.x - handle_size;
+          size.width = allocation.width - pos.x - handle_size;
         }
       else
         {
           size.width = pos.x;
         }
 
-      size.width -= GTK_CONTAINER (xpaned)->border_width;
+      size.width -= gtk_container_get_border_width (GTK_CONTAINER (xpaned));
 
       size.width =
         CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x);
@@ -1531,10 +1529,8 @@ update_drag (GtkXPaned * xpaned)
           gtk_widget_style_get (GTK_WIDGET (xpaned),
                                 "handle-size", &handle_size, NULL);
 
-          size.width =
-            GTK_WIDGET (xpaned)->allocation.width - pos.x - handle_size;
-          size.height =
-            GTK_WIDGET (xpaned)->allocation.height - pos.y - handle_size;
+          size.width = allocation.width - pos.x - handle_size;
+          size.height = allocation.height - pos.y - handle_size;
         }
       else
         {
@@ -1542,8 +1538,8 @@ update_drag (GtkXPaned * xpaned)
           size.height = pos.y;
         }
 
-      size.width -= GTK_CONTAINER (xpaned)->border_width;
-      size.height -= GTK_CONTAINER (xpaned)->border_width;
+      size.width -= gtk_container_get_border_width (GTK_CONTAINER (xpaned));
+      size.height -= gtk_container_get_border_width (GTK_CONTAINER (xpaned));
 
       size.width =
         CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x);
@@ -1659,9 +1655,9 @@ gtk_xpaned_focus (GtkWidget * widget, GtkDirectionType direction)
    * excessive cut-and-paste from gtkcontainer.c?
    */
 
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+  gtk_widget_set_can_focus (GTK_WIDGET (widget), FALSE);
   retval = (*GTK_WIDGET_CLASS (parent_class)->focus) (widget, direction);
-  GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+  gtk_widget_set_can_focus (GTK_WIDGET (widget), TRUE);
 
   return retval;
 }
@@ -2495,7 +2491,7 @@ gtk_xpaned_compute_position (GtkXPaned * xpaned,
   GdkPoint old_min_position;
   GdkPoint old_max_position;
   gint handle_size;
-  gint border_width = GTK_CONTAINER (xpaned)->border_width;
+  gint border_width = gtk_container_get_border_width (GTK_CONTAINER (xpaned));
 
   g_return_if_fail (GTK_IS_XPANED (xpaned));
 
@@ -2547,7 +2543,7 @@ gtk_xpaned_compute_position (GtkXPaned * xpaned,
   else
     {
       /* If the position was set before the initial allocation.
-       ** (paned->last_allocation <= 0) just clamp it and leave it. */
+      ** (paned->last_allocation <= 0) just clamp it and leave it. */
       if (xpaned->last_allocation.width > 0)
         {
           if (xpaned->top_left_child_resize
@@ -2563,15 +2559,15 @@ gtk_xpaned_compute_position (GtkXPaned * xpaned,
             if (!
                 (!xpaned->top_left_child_resize
                  && xpaned->top_right_child_resize))
-            {
-              xpaned->top_left_child_size.width = allocation->width
-                * ((gdouble) xpaned->top_left_child_size.width /
-                   (xpaned->last_allocation.width)) + 0.5;
-
-              xpaned->top_left_child_size.height = allocation->height
-                * ((gdouble) xpaned->top_left_child_size.height /
-                   (xpaned->last_allocation.height)) + 0.5;
-            }
+              {
+                xpaned->top_left_child_size.width = allocation->width
+                  * ((gdouble) xpaned->top_left_child_size.width /
+                     (xpaned->last_allocation.width)) + 0.5;
+
+                xpaned->top_left_child_size.height = allocation->height
+                  * ((gdouble) xpaned->top_left_child_size.height /
+                     (xpaned->last_allocation.height)) + 0.5;
+              }
         }
       if (xpaned->last_allocation.height > 0)
         {
@@ -2587,16 +2583,16 @@ gtk_xpaned_compute_position (GtkXPaned * xpaned,
             if (!
                 (!xpaned->top_left_child_resize
                  && xpaned->top_right_child_resize))
-            {
-              xpaned->top_left_child_size.width =
-                allocation->width *
-                ((gdouble) xpaned->top_left_child_size.width /
-                 (xpaned->last_allocation.width)) + 0.5;
-              xpaned->top_left_child_size.height =
-                allocation->height *
-                ((gdouble) xpaned->top_left_child_size.height /
-                 (xpaned->last_allocation.height)) + 0.5;
-            }
+              {
+                xpaned->top_left_child_size.width =
+                  allocation->width *
+                  ((gdouble) xpaned->top_left_child_size.width /
+                   (xpaned->last_allocation.width)) + 0.5;
+                xpaned->top_left_child_size.height =
+                  allocation->height *
+                  ((gdouble) xpaned->top_left_child_size.height /
+                   (xpaned->last_allocation.height)) + 0.5;
+              }
         }
 
     }
@@ -2782,7 +2778,7 @@ xpaned_get_focus_widget (GtkXPaned * xpaned)
 
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (xpaned));
   if (gtk_widget_is_toplevel (toplevel))
-    return GTK_WINDOW (toplevel)->focus_widget;
+    return gtk_window_get_focus (GTK_WINDOW (toplevel));
 
   return NULL;
 }
@@ -2808,17 +2804,17 @@ gtk_xpaned_set_focus_child (GtkContainer * container, GtkWidget * focus_child)
           /* If there is one or more paned widgets between us and the
            * focus widget, we want the topmost of those as last_focus
            */
-          for (w = last_focus; w != GTK_WIDGET (xpaned); w = w->parent)
+          for (w = last_focus; w != GTK_WIDGET (xpaned); w = gtk_widget_get_parent (w))
             if (GTK_IS_XPANED (w))
               last_focus = w;
 
-          if (container->focus_child == xpaned->top_left_child)
+          if (gtk_container_get_focus_child (container) == xpaned->top_left_child)
             gtk_xpaned_set_last_top_left_child_focus (xpaned, last_focus);
-          else if (container->focus_child == xpaned->top_right_child)
+          else if (gtk_container_get_focus_child (container) == xpaned->top_right_child)
             gtk_xpaned_set_last_top_right_child_focus (xpaned, last_focus);
-          else if (container->focus_child == xpaned->bottom_left_child)
+          else if (gtk_container_get_focus_child (container) == xpaned->bottom_left_child)
             gtk_xpaned_set_last_bottom_left_child_focus (xpaned, last_focus);
-          else if (container->focus_child == xpaned->bottom_right_child)
+          else if (gtk_container_get_focus_child (container) == xpaned->bottom_right_child)
             gtk_xpaned_set_last_bottom_right_child_focus (xpaned, last_focus);
         }
     }
@@ -2869,8 +2865,8 @@ gtk_xpaned_get_cycle_chain (GtkXPaned * xpaned,
       gtk_xpaned_set_last_bottom_right_child_focus (xpaned, NULL);
     }
 
-  if (GTK_WIDGET (xpaned)->parent)
-    ancestor = gtk_widget_get_ancestor (GTK_WIDGET (xpaned)->parent,
+  if (gtk_widget_get_parent (GTK_WIDGET (xpaned)))
+    ancestor = gtk_widget_get_ancestor (gtk_widget_get_parent (GTK_WIDGET (xpaned)),
                                         GTK_TYPE_XPANED);
 
   /* The idea here is that temp_list is a list of widgets we want to cycle
@@ -2883,28 +2879,28 @@ gtk_xpaned_get_cycle_chain (GtkXPaned * xpaned,
    */
   if (direction == GTK_DIR_TAB_FORWARD)
     {
-      if (container->focus_child == xpaned->top_left_child)
+      if (gtk_container_get_focus_child (container) == xpaned->top_left_child)
         {
           temp_list =
             g_list_append (temp_list, xpaned->last_top_right_child_focus);
           temp_list = g_list_append (temp_list, xpaned->top_right_child);
           temp_list = g_list_append (temp_list, ancestor);
         }
-      else if (container->focus_child == xpaned->top_right_child)
+      else if (gtk_container_get_focus_child (container) == xpaned->top_right_child)
         {
           temp_list = g_list_append (temp_list, ancestor);
           temp_list =
             g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
           temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
         }
-      else if (container->focus_child == xpaned->bottom_left_child)
+      else if (gtk_container_get_focus_child (container) == xpaned->bottom_left_child)
         {
           temp_list = g_list_append (temp_list, ancestor);
           temp_list =
             g_list_append (temp_list, xpaned->last_bottom_right_child_focus);
           temp_list = g_list_append (temp_list, xpaned->bottom_right_child);
         }
-      else if (container->focus_child == xpaned->bottom_right_child)
+      else if (gtk_container_get_focus_child (container) == xpaned->bottom_right_child)
         {
           temp_list = g_list_append (temp_list, ancestor);
           temp_list =
@@ -2930,28 +2926,28 @@ gtk_xpaned_get_cycle_chain (GtkXPaned * xpaned,
     }
   else
     {
-      if (container->focus_child == xpaned->top_left_child)
+      if (gtk_container_get_focus_child (container) == xpaned->top_left_child)
         {
           temp_list = g_list_append (temp_list, ancestor);
           temp_list =
             g_list_append (temp_list, xpaned->last_top_right_child_focus);
           temp_list = g_list_append (temp_list, xpaned->top_right_child);
         }
-      else if (container->focus_child == xpaned->top_right_child)
+      else if (gtk_container_get_focus_child (container) == xpaned->top_right_child)
         {
           temp_list =
             g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
           temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
           temp_list = g_list_append (temp_list, ancestor);
         }
-      else if (container->focus_child == xpaned->bottom_right_child)
+      else if (gtk_container_get_focus_child (container) == xpaned->bottom_right_child)
         {
           temp_list =
             g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
           temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
           temp_list = g_list_append (temp_list, ancestor);
         }
-      else if (container->focus_child == xpaned->top_right_child)
+      else if (gtk_container_get_focus_child (container) == xpaned->top_right_child)
         {
           temp_list =
             g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
@@ -3057,7 +3053,7 @@ get_all_xpanes (GtkXPaned * xpaned)
   GList *result = NULL;
   GtkWidget *w;
 
-  for (w = GTK_WIDGET (xpaned); w != NULL; w = w->parent)
+  for (w = GTK_WIDGET (xpaned); w != NULL; w = gtk_widget_get_parent (w))
     {
       if (GTK_IS_XPANED (w))
         topmost = GTK_XPANED (w);
@@ -3323,7 +3319,7 @@ gtk_xpaned_cycle_handle_focus (GtkXPaned * xpaned, gboolean reversed)
 
       gtk_xpaned_find_neighbours (xpaned, &next, &prev);
 
-      if (container->focus_child == xpaned->top_left_child)
+      if (gtk_container_get_focus_child (container) == xpaned->top_left_child)
         {
           if (reversed)
             {
@@ -3336,7 +3332,7 @@ gtk_xpaned_cycle_handle_focus (GtkXPaned * xpaned, gboolean reversed)
               first = xpaned;
             }
         }
-      else if (container->focus_child == xpaned->top_right_child)
+      else if (gtk_container_get_focus_child (container) == xpaned->top_right_child)
         {
           if (reversed)
             {
@@ -3367,7 +3363,7 @@ gtk_xpaned_cycle_handle_focus (GtkXPaned * xpaned, gboolean reversed)
 
       if (GTK_IS_WINDOW (toplevel))
         gtk_xpaned_set_saved_focus (focus,
-                                    GTK_WINDOW (toplevel)->focus_widget);
+                                    gtk_window_get_focus (GTK_WINDOW (toplevel)));
       gtk_xpaned_set_first_xpaned (focus, first);
       focus->original_position.x = gtk_xpaned_get_position_x (focus);
       focus->original_position.y = gtk_xpaned_get_position_y (focus);