[gtk/ebassi/inout-args] Remove pointless inout arguments




commit 153c6424d3aa983c3679a7ebf640d0b2b21fc26a
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Nov 17 14:40:52 2020 +0000

    Remove pointless inout arguments
    
    GtkTreeView.get_tooltip_context() takes an inout X and Y coordinates,
    but the "out" side is a side effect: the conversion from widget-relative
    to bin window-relative coordinates is not documented, and can be done
    using public API, if needed.
    
    GtkIconView.get_tooltip_context() follows the same pattern, and takes
    two inout arguments for the coordinates, but it does not change them any
    more, after GtkIconView's bin window was dropped in commit 8dc5e13e.
    
    There's really no point in having these `inout` arguments, and while
    GtkTreeView and GtkIconView are certainly de-emphasised in GTK4, and we
    nudge developers to move to the new list views, we should take advantage
    of the API break to remove warts.

 docs/reference/gtk/migrating-3to4.md |  8 ++++++++
 gtk/gtkfilechooserwidget.c           |  2 +-
 gtk/gtkiconview.c                    | 14 ++++++--------
 gtk/gtkiconview.h                    |  4 ++--
 gtk/gtktreeview.c                    | 20 ++++++++++----------
 gtk/gtktreeview.h                    |  4 ++--
 tests/testtooltips.c                 |  2 +-
 7 files changed, 30 insertions(+), 24 deletions(-)
---
diff --git a/docs/reference/gtk/migrating-3to4.md b/docs/reference/gtk/migrating-3to4.md
index 14591ecb86..8a4fc9f32e 100644
--- a/docs/reference/gtk/migrating-3to4.md
+++ b/docs/reference/gtk/migrating-3to4.md
@@ -1136,6 +1136,14 @@ gtk_buildable_get_buildable_id().
 GtkAboutDialog now directly derives from GtkWindow, the GtkDialog API can no
 longer be used on it.
 
+### Adapt to GtkTreeView and GtkIconView tooltip context changes
+
+The getter functions for retrieving the data from #GtkTreeView
+and #GtkIconView inside a #GtkWidget::query-tooltip signal do not take the
+pointer coordinates as inout arguments any more, but as normal in ones.
+
+See: gtk_tree_view_get_tooltip_context(), gtk_icon_view_get_tooltip_context()
+
 ## Changes to consider after the switch
 
 GTK 4 has a number of new features that you may want to take
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index b063dd7a60..dd1cb284cf 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -2111,7 +2111,7 @@ file_list_query_tooltip_cb (GtkWidget  *widget,
 
 
   if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (impl->browse_files_tree_view),
-                                          &x, &y,
+                                          x, y,
                                           keyboard_tip,
                                           &model, &path, &iter))
     return FALSE;
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index ac4912a06e..5d24c1f0bf 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -4254,8 +4254,8 @@ gtk_icon_view_set_tooltip_cell (GtkIconView     *icon_view,
 /**
  * gtk_icon_view_get_tooltip_context:
  * @icon_view: an #GtkIconView
- * @x: (inout): the x coordinate (relative to widget coordinates)
- * @y: (inout): the y coordinate (relative to widget coordinates)
+ * @x: the x coordinate (relative to widget coordinates)
+ * @y: the y coordinate (relative to widget coordinates)
  * @keyboard_tip: whether this is a keyboard tooltip or not
  * @model: (out) (allow-none) (transfer none): a pointer to receive a
  *         #GtkTreeModel or %NULL
@@ -4277,8 +4277,8 @@ gtk_icon_view_set_tooltip_cell (GtkIconView     *icon_view,
  */
 gboolean
 gtk_icon_view_get_tooltip_context (GtkIconView   *icon_view,
-                                   int           *x,
-                                   int           *y,
+                                   int            x,
+                                   int            y,
                                    gboolean       keyboard_tip,
                                    GtkTreeModel **model,
                                    GtkTreePath  **path,
@@ -4287,8 +4287,6 @@ gtk_icon_view_get_tooltip_context (GtkIconView   *icon_view,
   GtkTreePath *tmppath = NULL;
 
   g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), FALSE);
-  g_return_val_if_fail (x != NULL, FALSE);
-  g_return_val_if_fail (y != NULL, FALSE);
 
   if (keyboard_tip)
     {
@@ -4299,7 +4297,7 @@ gtk_icon_view_get_tooltip_context (GtkIconView   *icon_view,
     }
   else
     {
-      if (!gtk_icon_view_get_item_at_pos (icon_view, *x, *y, &tmppath, NULL))
+      if (!gtk_icon_view_get_item_at_pos (icon_view, x, y, &tmppath, NULL))
         return FALSE;
     }
 
@@ -4333,7 +4331,7 @@ gtk_icon_view_set_tooltip_query_cb (GtkWidget  *widget,
   GtkIconView *icon_view = GTK_ICON_VIEW (widget);
 
   if (!gtk_icon_view_get_tooltip_context (GTK_ICON_VIEW (widget),
-                                          &x, &y,
+                                          x, y,
                                           keyboard_tip,
                                           &model, &path, &iter))
     return FALSE;
diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h
index 022b455188..7a204b54d9 100644
--- a/gtk/gtkiconview.h
+++ b/gtk/gtkiconview.h
@@ -268,8 +268,8 @@ void    gtk_icon_view_set_tooltip_cell                        (GtkIconView     *
                                                                GtkCellRenderer *cell);
 GDK_AVAILABLE_IN_ALL
 gboolean gtk_icon_view_get_tooltip_context                    (GtkIconView       *icon_view,
-                                                               int               *x,
-                                                               int               *y,
+                                                               int                x,
+                                                               int                y,
                                                                gboolean           keyboard_tip,
                                                                GtkTreeModel     **model,
                                                                GtkTreePath      **path,
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 8cfb238deb..f404eec9e4 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -14676,8 +14676,8 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView       *tree_view,
 /**
  * gtk_tree_view_get_tooltip_context:
  * @tree_view: a #GtkTreeView
- * @x: (inout): the x coordinate (relative to widget coordinates)
- * @y: (inout): the y coordinate (relative to widget coordinates)
+ * @x: the x coordinate (relative to widget coordinates)
+ * @y: the y coordinate (relative to widget coordinates)
  * @keyboard_tip: whether this is a keyboard tooltip or not
  * @model: (out) (optional) (nullable) (transfer none): a pointer to
  *         receive a #GtkTreeModel or %NULL
@@ -14700,8 +14700,8 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView       *tree_view,
  */
 gboolean
 gtk_tree_view_get_tooltip_context (GtkTreeView   *tree_view,
-                                  int           *x,
-                                  int           *y,
+                                  int            x,
+                                  int            y,
                                   gboolean       keyboard_tip,
                                   GtkTreeModel **model,
                                   GtkTreePath  **path,
@@ -14710,8 +14710,6 @@ gtk_tree_view_get_tooltip_context (GtkTreeView   *tree_view,
   GtkTreePath *tmppath = NULL;
 
   g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
-  g_return_val_if_fail (x != NULL, FALSE);
-  g_return_val_if_fail (y != NULL, FALSE);
 
   if (keyboard_tip)
     {
@@ -14722,10 +14720,12 @@ gtk_tree_view_get_tooltip_context (GtkTreeView   *tree_view,
     }
   else
     {
-      gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, *x, *y,
-                                                         x, y);
+      int rel_x, rel_y;
 
-      if (!gtk_tree_view_get_path_at_pos (tree_view, *x, *y,
+      gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y,
+                                                         &rel_x, &rel_y);
+
+      if (!gtk_tree_view_get_path_at_pos (tree_view, rel_x, rel_y,
                                          &tmppath, NULL, NULL, NULL))
        return FALSE;
     }
@@ -14762,7 +14762,7 @@ gtk_tree_view_set_tooltip_query_cb (GtkWidget  *widget,
   GtkTreeViewPrivate *priv = gtk_tree_view_get_instance_private (tree_view);
 
   if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget),
-                                         &x, &y,
+                                         x, y,
                                          keyboard_tip,
                                          &model, &path, &iter))
     return FALSE;
diff --git a/gtk/gtktreeview.h b/gtk/gtktreeview.h
index c323c7d957..0910ad23ac 100644
--- a/gtk/gtktreeview.h
+++ b/gtk/gtktreeview.h
@@ -528,8 +528,8 @@ void          gtk_tree_view_set_tooltip_cell   (GtkTreeView       *tree_view,
                                                GtkCellRenderer   *cell);
 GDK_AVAILABLE_IN_ALL
 gboolean      gtk_tree_view_get_tooltip_context(GtkTreeView       *tree_view,
-                                               int               *x,
-                                               int               *y,
+                                               int                x,
+                                               int                y,
                                                gboolean           keyboard_tip,
                                                GtkTreeModel     **model,
                                                GtkTreePath      **path,
diff --git a/tests/testtooltips.c b/tests/testtooltips.c
index 2cc4bf9c96..80f60b67cc 100644
--- a/tests/testtooltips.c
+++ b/tests/testtooltips.c
@@ -125,7 +125,7 @@ query_tooltip_tree_view_cb (GtkWidget  *widget,
 
   char buffer[512];
 
-  if (!gtk_tree_view_get_tooltip_context (tree_view, &x, &y,
+  if (!gtk_tree_view_get_tooltip_context (tree_view, x, y,
                                          keyboard_tip,
                                          &model, &path, &iter))
     return FALSE;


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