From 4c40014a86ed3e97c88e196db253b919045ea148 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 11 Jul 2007 18:14:46 +0000 Subject: [PATCH] New function to convert widget coords to what is expected by the at_pos 2007-07-11 Matthias Clasen * gtk/gtk.symbols: * gtk/gtkiconview.[hc] (gtk_icon_view_convert_widget_to_bin_window_coords): New function to convert widget coords to what is expected by the at_pos functions. (#455984) svn path=/trunk/; revision=18445 --- ChangeLog | 13 +++++++++ docs/reference/ChangeLog | 4 +++ docs/reference/gtk/gtk-sections.txt | 1 + gtk/gtk.symbols | 1 + gtk/gtkiconview.c | 44 +++++++++++++++++++++++++++-- gtk/gtkiconview.h | 6 ++++ 6 files changed, 66 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8227fdb2a9..71197c0ce0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-07-11 Matthias Clasen + + * gtk/gtk.symbols: + * gtk/gtkiconview.[hc] + (gtk_icon_view_convert_widget_to_bin_window_coords): New + function to convert widget coords to what is expected by + the at_pos functions. (#455984) + +2007-07-11 Matthias Clasen + + * gtk/gtkwiget.c: Don't include gtktooltips.h, it is + not needed anymore. + 2007-07-11 Christian Persch * gtk/gtkaction.c: (gtk_action_buildable_set_name), diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 0b26c720ee..a6c00e11e5 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2007-07-11 Matthias Clasen + + * gtk/gtk-sections.txt: Updates + 2007-07-11 Matthias Clasen * gtk/migrating-GtkTooltip.sgml: Migration chapter diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 7a45354254..acdb2f419a 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -1780,6 +1780,7 @@ gtk_icon_view_set_pixbuf_column gtk_icon_view_get_pixbuf_column gtk_icon_view_get_path_at_pos gtk_icon_view_get_item_at_pos +gtk_icon_view_convert_widget_to_bin_window_coords gtk_icon_view_set_cursor gtk_icon_view_get_cursor gtk_icon_view_selected_foreach diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index bbd4e9d4c7..b99de6773f 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -1844,6 +1844,7 @@ gtk_icon_view_get_model gtk_icon_view_get_orientation gtk_icon_view_get_path_at_pos gtk_icon_view_get_item_at_pos +gtk_icon_view_convert_widget_to_bin_window_coords gtk_icon_view_get_pixbuf_column gtk_icon_view_get_row_spacing gtk_icon_view_get_selected_items diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 96e09eb33a..88d75543d4 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -4518,6 +4518,39 @@ gtk_icon_view_new_with_model (GtkTreeModel *model) return g_object_new (GTK_TYPE_ICON_VIEW, "model", model, NULL); } +/** + * gtk_icon_view_convert_widget_to_bin_window_coords: + * @wx: X coordinate relative to the widget + * @wy: Y coordinate relative to the widget + * @bx: return location for bin_window X coordinate + * @by: return location for bin_window Y coordinate + * + * Converts widget coordinates to coordinates for the bin_window, + * as expected by e.g. gtk_icon_view_get_path_at_pos(). + * + * Since: 2.12 + */ +void +gtk_icon_view_convert_widget_to_bin_window_coords (GtkIconView *icon_view, + gint wx, + gint wy, + gint *bx, + gint *by) +{ + gint x, y; + + g_return_if_fail (GTK_IS_ICON_VIEW (icon_view)); + + if (icon_view->priv->bin_window) + gdk_window_get_position (icon_view->priv->bin_window, &x, &y); + else + x = y = 0; + + if (bx) + *bx = wx - x; + if (by) + *by = wy - y; +} /** * gtk_icon_view_get_path_at_pos: @@ -4525,9 +4558,11 @@ gtk_icon_view_new_with_model (GtkTreeModel *model) * @x: The x position to be identified * @y: The y position to be identified * - * Finds the path at the point (@x, @y), relative to widget coordinates. + * Finds the path at the point (@x, @y), relative to bin_window coordinates. * See gtk_icon_view_get_item_at_pos(), if you are also interested in - * the cell at the specified position. + * the cell at the specified position. + * See gtk_icon_view_convert_widget_to_bin_window_coords() for converting + * widget coordinates to bin_window coordinates. * * Return value: The #GtkTreePath corresponding to the icon or %NULL * if no icon exists at that position. @@ -4541,6 +4576,7 @@ gtk_icon_view_get_path_at_pos (GtkIconView *icon_view, { GtkIconViewItem *item; GtkTreePath *path; + gint px, py; g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), NULL); @@ -4563,10 +4599,12 @@ gtk_icon_view_get_path_at_pos (GtkIconView *icon_view, * @cell: Return location for the renderer responsible for the cell * at (@x, @y), or %NULL * - * Finds the path at the point (@x, @y), relative to widget coordinates. + * Finds the path at the point (@x, @y), relative to bin_window coordinates. * In contrast to gtk_icon_view_get_path_at_pos(), this function also * obtains the cell at the specified position. The returned path should * be freed with gtk_tree_path_free(). + * See gtk_icon_view_convert_widget_to_bin_window_coords() for converting + * widget coordinates to bin_window coordinates. * * Return value: %TRUE if an item exists at the specified position * diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h index b6e5d46bed..62780c3f81 100644 --- a/gtk/gtkiconview.h +++ b/gtk/gtkiconview.h @@ -195,6 +195,12 @@ gboolean gtk_icon_view_get_dest_item_at_pos (GtkIconView GdkPixmap *gtk_icon_view_create_drag_icon (GtkIconView *icon_view, GtkTreePath *path); +void gtk_icon_view_convert_widget_to_bin_window_coords (GtkIconView *icon_view, + gint wx, + gint wy, + gint *bx, + gint *by); + G_END_DECLS