[gtk+] treeview: Remove gtk_tree_view_get_bin_window()



commit d50b73f66db7946dd0d50a189c6d11f2273d559f
Author: Benjamin Otte <otte redhat com>
Date:   Sat Jan 7 16:07:21 2017 +0100

    treeview: Remove gtk_tree_view_get_bin_window()
    
    We don't want to expose GdkWindows in the public API.

 docs/reference/gtk/gtk4-sections.txt |    1 -
 gtk/a11y/gtktextcellaccessible.c     |   16 +++++++++----
 gtk/a11y/gtktreeviewaccessible.c     |   14 ++++++------
 gtk/gtkrecentchooserdefault.c        |    3 --
 gtk/gtktreeview.c                    |   38 +++++++--------------------------
 gtk/gtktreeview.h                    |    2 -
 tests/testtreeedit.c                 |    5 +--
 7 files changed, 28 insertions(+), 51 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 220d5c3..52ee414 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -3922,7 +3922,6 @@ gtk_tree_view_get_cell_area
 gtk_tree_view_get_background_area
 gtk_tree_view_get_visible_rect
 gtk_tree_view_get_visible_range
-gtk_tree_view_get_bin_window
 gtk_tree_view_convert_bin_window_to_tree_coords
 gtk_tree_view_convert_bin_window_to_widget_coords
 gtk_tree_view_convert_tree_to_bin_window_coords
diff --git a/gtk/a11y/gtktextcellaccessible.c b/gtk/a11y/gtktextcellaccessible.c
index 24fc72b..a64df61 100644
--- a/gtk/a11y/gtktextcellaccessible.c
+++ b/gtk/a11y/gtktextcellaccessible.c
@@ -486,14 +486,20 @@ get_origins (GtkWidget *widget,
 {
   GdkWindow *window;
 
-  if (GTK_IS_TREE_VIEW (widget))
-    window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
-  else
-    window = gtk_widget_get_window (widget);
-
+  window = gtk_widget_get_window (widget);
   gdk_window_get_origin (window, x_window, y_window);
   window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
   gdk_window_get_origin (window, x_toplevel, y_toplevel);
+
+  if (GTK_IS_TREE_VIEW (widget))
+    {
+      gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget),
+                                                         *x_window, *y_window,
+                                                         x_window, y_window);
+      gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget),
+                                                         *x_toplevel, *y_toplevel,
+                                                         x_toplevel, y_toplevel);
+    }
 }
 
 static void
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index a95054d..65a68f3 100644
--- a/gtk/a11y/gtktreeviewaccessible.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -1081,7 +1081,6 @@ gtk_tree_view_accessible_get_cell_extents (GtkCellAccessibleParent *parent,
 {
   GtkWidget *widget;
   GtkTreeView *tree_view;
-  GdkWindow *bin_window;
   GdkRectangle cell_rect;
   gint w_x, w_y;
 
@@ -1091,19 +1090,20 @@ gtk_tree_view_accessible_get_cell_extents (GtkCellAccessibleParent *parent,
 
   tree_view = GTK_TREE_VIEW (widget);
   gtk_tree_view_accessible_get_cell_area (parent, cell, &cell_rect);
-  bin_window = gtk_tree_view_get_bin_window (tree_view);
-  gdk_window_get_origin (bin_window, &w_x, &w_y);
+  gtk_tree_view_convert_widget_to_bin_window_coords (tree_view,
+                                                     0, 0, 
+                                                     &w_x, &w_y);
 
-  if (coord_type == ATK_XY_WINDOW)
+  if (coord_type != ATK_XY_WINDOW)
     {
       GdkWindow *window;
       gint x_toplevel, y_toplevel;
 
-      window = gdk_window_get_toplevel (bin_window);
+      window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
       gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
 
-      w_x -= x_toplevel;
-      w_y -= y_toplevel;
+      w_x += x_toplevel;
+      w_y += y_toplevel;
     }
 
   *width = cell_rect.width;
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 1e1a3f6..f6c74da 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -1718,9 +1718,6 @@ recent_view_button_press_cb (GtkWidget      *widget,
       GtkTreePath *path;
       gboolean res;
 
-      if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (impl->priv->recent_view)))
-        return FALSE;
-
       res = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (impl->priv->recent_view),
                                           event->x, event->y,
                                           &path,
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 19c60e5..206d3c0 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -13014,25 +13014,6 @@ gtk_tree_view_set_cursor_on_cell (GtkTreeView       *tree_view,
 }
 
 /**
- * gtk_tree_view_get_bin_window:
- * @tree_view: A #GtkTreeView
- *
- * Returns the window that @tree_view renders to.
- * This is used primarily to compare to `event->window`
- * to confirm that the event on @tree_view is on the right window.
- *
- * Returns: (nullable) (transfer none): A #GdkWindow, or %NULL when @tree_view
- * hasn’t been realized yet.
- **/
-GdkWindow *
-gtk_tree_view_get_bin_window (GtkTreeView *tree_view)
-{
-  g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL);
-
-  return tree_view->priv->bin_window;
-}
-
-/**
  * gtk_tree_view_get_path_at_pos:
  * @tree_view: A #GtkTreeView.
  * @x: The x position to be identified (relative to bin_window).
@@ -13046,11 +13027,10 @@ gtk_tree_view_get_bin_window (GtkTreeView *tree_view)
  * @cell_y: (out) (optional): A pointer where the Y coordinate
  *   relative to the cell can be placed, or %NULL
  *
- * Finds the path at the point (@x, @y), relative to bin_window coordinates
- * (please see gtk_tree_view_get_bin_window()).
- * That is, @x and @y are relative to an events coordinates. @x and @y must
- * come from an event on the @tree_view only where `event->window ==
- * gtk_tree_view_get_bin_window ()`. It is primarily for
+ * Finds the path at the point (@x, @y), relative to bin_window coordinates.
+ * That is, @x and @y are relative to an events coordinates. Widget-relative
+ * coordinates must be converted using
+ * gtk_tree_view_convert_widget_to_bin_window_coords(). It is primarily for
  * things like popup menus. If @path is non-%NULL, then it will be filled
  * with the #GtkTreePath at that point.  This path should be freed with
  * gtk_tree_path_free().  If @column is non-%NULL, then it will be filled
@@ -13491,8 +13471,7 @@ gtk_tree_view_convert_tree_to_widget_coords (GtkTreeView *tree_view,
  * @bx: (out): return location for bin_window X coordinate
  * @by: (out): return location for bin_window Y coordinate
  *
- * Converts widget coordinates to coordinates for the bin_window
- * (see gtk_tree_view_get_bin_window()).
+ * Converts widget coordinates to coordinates for the bin_window.
  *
  * Since: 2.12
  **/
@@ -13519,8 +13498,7 @@ gtk_tree_view_convert_widget_to_bin_window_coords (GtkTreeView *tree_view,
  * @wx: (out): return location for widget X coordinate
  * @wy: (out): return location for widget Y coordinate
  *
- * Converts bin_window coordinates (see gtk_tree_view_get_bin_window())
- * to widget relative coordinates.
+ * Converts bin_window coordinates to widget relative coordinates.
  *
  * Since: 2.12
  **/
@@ -13676,8 +13654,8 @@ gtk_tree_view_get_visible_range (GtkTreeView  *tree_view,
  * selection, having a custom context menu or starting rubber banding.
  *
  * The @x and @y coordinate that are provided must be relative to bin_window
- * coordinates.  That is, @x and @y must come from an event on @tree_view
- * where `event->window == gtk_tree_view_get_bin_window ()`.
+ * coordinates.  Widget-relative coordinates must be converted using
+ * gtk_tree_view_convert_widget_to_bin_window_coords().
  *
  * For converting widget coordinates (eg. the ones you get from
  * GtkWidget::query-tooltip), please see
diff --git a/gtk/gtktreeview.h b/gtk/gtktreeview.h
index b1ac055..da4062b 100644
--- a/gtk/gtktreeview.h
+++ b/gtk/gtktreeview.h
@@ -345,8 +345,6 @@ void                   gtk_tree_view_get_cursor                    (GtkTreeView
 
 /* Layout information */
 GDK_AVAILABLE_IN_ALL
-GdkWindow             *gtk_tree_view_get_bin_window                (GtkTreeView               *tree_view);
-GDK_AVAILABLE_IN_ALL
 gboolean               gtk_tree_view_get_path_at_pos               (GtkTreeView               *tree_view,
                                                                    gint                       x,
                                                                    gint                       y,
diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c
index 676ec72..994f034 100644
--- a/tests/testtreeedit.c
+++ b/tests/testtreeedit.c
@@ -137,9 +137,8 @@ static gboolean
 button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer callback_data)
 {
        /* Deselect if people click outside any row. */
-       if (event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))
-           && !gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
-                                              event->x, event->y, NULL, NULL, NULL, NULL)) {
+       if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
+                                           event->x, event->y, NULL, NULL, NULL, NULL)) {
                gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)));
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]