Fix some typos (found by codespell)
[pspp] / lib / gtk-contrib / gtkxpaned.c
index 8bd5253deae0f8c75db34c273b51d87b61931fcb..d5b9c843e57d5837d3a0fe2ebe4e470d07661e3c 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 
+ **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+
@@ -529,10 +529,10 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
   /**
    * GtkPaned:resize:
    *
-   * The "resize" child property determines whether the child expands and 
+   * The "resize" child property determines whether the child expands and
    * shrinks along with the paned widget.
-   * 
-   * Since: 2.4 
+   *
+   * Since: 2.4
    */
   gtk_container_class_install_child_property (container_class,
                                               CHILD_PROP_RESIZE,
@@ -545,10 +545,10 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
   /**
    * GtkPaned:shrink:
    *
-   * The "shrink" child property determines whether the child can be made 
+   * The "shrink" child property determines whether the child can be made
    * smaller than its requisition.
-   * 
-   * Since: 2.4 
+   *
+   * Since: 2.4
    */
   gtk_container_class_install_child_property (container_class,
                                               CHILD_PROP_SHRINK,
@@ -952,7 +952,7 @@ gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
                                   xpaned->handle_pos_middle.height);
         }
 
-      /* Now allocate the childen, making sure, when resizing not to
+      /* Now allocate the children, making sure, when resizing not to
        * overlap the windows
        */
       if (gtk_widget_get_mapped (widget))
@@ -1480,6 +1480,11 @@ update_drag (GtkXPaned * xpaned)
                                     gdk_display_get_device_manager (
                                       gtk_widget_get_display (widget))),
                                   &pos.x, &pos.y, NULL);
+  if (!gtk_widget_get_has_window (widget))
+    {
+      pos.x -= allocation.x;
+      pos.y -= allocation.y;
+    }
 
   if (xpaned->in_drag_vert)
     {
@@ -1671,6 +1676,22 @@ gtk_xpaned_focus (GtkWidget * widget, GtkDirectionType direction)
   return retval;
 }
 
+static void
+gtk_xpaned_button_press_grab (GdkWindow *handle, GdkEventButton *event)
+{
+  /* We need a server grab here, not gtk_grab_add(), since
+   * we don't want to pass events on to the widget's children */
+  gdk_device_grab (event->device, handle,
+                   GDK_OWNERSHIP_NONE,
+                   FALSE,
+                   (GDK_POINTER_MOTION_HINT_MASK
+                    | GDK_BUTTON1_MOTION_MASK
+                    | GDK_BUTTON_RELEASE_MASK
+                    | GDK_ENTER_NOTIFY_MASK
+                    | GDK_LEAVE_NOTIFY_MASK),
+                   NULL, event->time);
+}
+
 static gboolean
 gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event)
 {
@@ -1692,20 +1713,7 @@ gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event)
       event->window == xpaned->handle_middle && event->button == 1)
     {
       xpaned->in_drag_vert_and_horiz = TRUE;
-
-      /* We need a server grab here, not gtk_grab_add(), since
-       * we don't want to pass events on to the widget's children */
-      if (gdk_pointer_grab (xpaned->handle_middle,
-                            FALSE,
-                            GDK_POINTER_MOTION_HINT_MASK
-                            | GDK_BUTTON1_MOTION_MASK
-                            | GDK_BUTTON_RELEASE_MASK
-                            | GDK_ENTER_NOTIFY_MASK
-                            | GDK_LEAVE_NOTIFY_MASK,
-                            NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
-        {
-        }
-
+      gtk_xpaned_button_press_grab (xpaned->handle_middle, event);
       xpaned->drag_pos.x = event->x;
       xpaned->drag_pos.y = event->y;
 
@@ -1719,20 +1727,7 @@ gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event)
            event->window != xpaned->handle_middle && event->button == 1)
     {
       xpaned->in_drag_vert = TRUE;
-
-      /* We need a server grab here, not gtk_grab_add(), since
-       * we don't want to pass events on to the widget's children */
-      if (gdk_pointer_grab (xpaned->handle_east,
-                            FALSE,
-                            GDK_POINTER_MOTION_HINT_MASK
-                            | GDK_BUTTON1_MOTION_MASK
-                            | GDK_BUTTON_RELEASE_MASK
-                            | GDK_ENTER_NOTIFY_MASK
-                            | GDK_LEAVE_NOTIFY_MASK,
-                            NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
-        {
-        }
-
+      gtk_xpaned_button_press_grab (xpaned->handle_east, event);
       xpaned->drag_pos.y = event->y;
 
       return TRUE;
@@ -1745,20 +1740,7 @@ gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event)
            event->window != xpaned->handle_middle && event->button == 1)
     {
       xpaned->in_drag_vert = TRUE;
-
-      /* We need a server grab here, not gtk_grab_add(), since
-       * we don't want to pass events on to the widget's children */
-      if (gdk_pointer_grab (xpaned->handle_west,
-                            FALSE,
-                            GDK_POINTER_MOTION_HINT_MASK
-                            | GDK_BUTTON1_MOTION_MASK
-                            | GDK_BUTTON_RELEASE_MASK
-                            | GDK_ENTER_NOTIFY_MASK
-                            | GDK_LEAVE_NOTIFY_MASK,
-                            NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
-        {
-        }
-
+      gtk_xpaned_button_press_grab (xpaned->handle_west, event);
       xpaned->drag_pos.y = event->y;
 
       return TRUE;
@@ -1771,20 +1753,7 @@ gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event)
            event->window != xpaned->handle_middle && event->button == 1)
     {
       xpaned->in_drag_horiz = TRUE;
-
-      /* We need a server grab here, not gtk_grab_add(), since
-       * we don't want to pass events on to the widget's children */
-      if (gdk_pointer_grab (xpaned->handle_north,
-                            FALSE,
-                            GDK_POINTER_MOTION_HINT_MASK
-                            | GDK_BUTTON1_MOTION_MASK
-                            | GDK_BUTTON_RELEASE_MASK
-                            | GDK_ENTER_NOTIFY_MASK
-                            | GDK_LEAVE_NOTIFY_MASK,
-                            NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
-        {
-        }
-
+      gtk_xpaned_button_press_grab (xpaned->handle_north, event);
       xpaned->drag_pos.x = event->x;
 
       return TRUE;
@@ -1797,20 +1766,7 @@ gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event)
            event->window != xpaned->handle_middle && event->button == 1)
     {
       xpaned->in_drag_horiz = TRUE;
-
-      /* We need a server grab here, not gtk_grab_add(), since
-       * we don't want to pass events on to the widget's children */
-      if (gdk_pointer_grab (xpaned->handle_south,
-                            FALSE,
-                            GDK_POINTER_MOTION_HINT_MASK
-                            | GDK_BUTTON1_MOTION_MASK
-                            | GDK_BUTTON_RELEASE_MASK
-                            | GDK_ENTER_NOTIFY_MASK
-                            | GDK_LEAVE_NOTIFY_MASK,
-                            NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
-        {
-        }
-
+      gtk_xpaned_button_press_grab (xpaned->handle_south, event);
       xpaned->drag_pos.x = event->x;
 
       return TRUE;
@@ -1828,8 +1784,7 @@ gtk_xpaned_button_release (GtkWidget * widget, GdkEventButton * event)
       xpaned->in_drag_vert = FALSE;
       xpaned->drag_pos.y = -1;
       xpaned->position_set = TRUE;
-      gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
-                                  event->time);
+      gdk_device_ungrab (event->device, event->time);
       return TRUE;
     }
   else if (xpaned->in_drag_horiz && (event->button == 1))
@@ -1837,8 +1792,7 @@ gtk_xpaned_button_release (GtkWidget * widget, GdkEventButton * event)
       xpaned->in_drag_horiz = FALSE;
       xpaned->drag_pos.x = -1;
       xpaned->position_set = TRUE;
-      gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
-                                  event->time);
+      gdk_device_ungrab (event->device, event->time);
       return TRUE;
     }
   else if (xpaned->in_drag_vert_and_horiz && (event->button == 1))
@@ -1847,8 +1801,7 @@ gtk_xpaned_button_release (GtkWidget * widget, GdkEventButton * event)
       xpaned->drag_pos.x = -1;
       xpaned->drag_pos.y = -1;
       xpaned->position_set = TRUE;
-      gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
-                                  event->time);
+      gdk_device_ungrab (event->device, event->time);
       return TRUE;
     }
 
@@ -2061,9 +2014,9 @@ gtk_xpaned_forall (GtkContainer * container,
 /**
  * gtk_xpaned_get_position_x:
  * @paned: a #GtkXPaned widget
- * 
+ *
  * Obtains the x-position of the divider.
- * 
+ *
  * Return value: x-position of the divider
  **/
 gint
@@ -2077,9 +2030,9 @@ gtk_xpaned_get_position_x (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_position_y:
  * @paned: a #GtkXPaned widget
- * 
+ *
  * Obtains the y-position of the divider.
- * 
+ *
  * Return value: y-position of the divider
  **/
 gint
@@ -2095,7 +2048,7 @@ gtk_xpaned_get_position_y (GtkXPaned * xpaned)
  * @paned: a #GtkXPaned widget
  * @xposition: pixel x-position of divider, a negative values
  *                        of a component mean that the position is unset.
- * 
+ *
  * Sets the x-position of the divider between the four panes.
  **/
 void
@@ -2144,7 +2097,7 @@ gtk_xpaned_set_position_x (GtkXPaned * xpaned, gint xposition)
  * @paned: a #GtkXPaned widget
  * @yposition: pixel y-position of divider, a negative values
  *                        of a component mean that the position is unset.
- * 
+ *
  * Sets the y-position of the divider between the four panes.
  **/
 void
@@ -2219,9 +2172,9 @@ gtk_xpaned_fetch_unmaximized_y (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_top_left_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the top-left child of the xpaned widget.
- * 
+ *
  * Return value: top-left child, or %NULL if it is not set.
  *
  * Since: 2.4
@@ -2237,9 +2190,9 @@ gtk_xpaned_get_top_left_child (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_top_right_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the top-right child of the xpaned widget.
- * 
+ *
  * Return value: top-right child, or %NULL if it is not set.
  *
  * Since: 2.4
@@ -2255,9 +2208,9 @@ gtk_xpaned_get_top_right_child (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_bottom_left_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the bottom-left child of the xpaned widget.
- * 
+ *
  * Return value: bottom-left child, or %NULL if it is not set.
  *
  * Since: 2.4
@@ -2273,9 +2226,9 @@ gtk_xpaned_get_bottom_left_child (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_bottom_right_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the bottom-right child of the xpaned widget.
- * 
+ *
  * Return value: bottom-right child, or %NULL if it is not set.
  *
  * Since: 2.4