[gtk/global-coords: 21/28] menu: Simplify function
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/global-coords: 21/28] menu: Simplify function
- Date: Thu, 30 May 2019 23:09:46 +0000 (UTC)
commit c3c327a82a94f63b23ebed361d05ac7cbfbfc003
Author: Benjamin Otte <otte redhat com>
Date: Thu Apr 25 01:27:58 2019 +0200
menu: Simplify function
No need to do complicated math when we can just look at the allocation.
gtk/gtkmenu.c | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index a4bc6be307..a0929d3cc7 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -3521,30 +3521,19 @@ compute_child_offset (GtkMenu *menu,
gint *height)
{
GtkMenuPrivate *priv = menu->priv;
- gint item_top_attach;
- gint child_offset = 0;
- gint i;
-
- get_effective_child_attach (menu_item, &item_top_attach);
-
- /* there is a possibility that we get called before _size_request,
- * so check the height table for safety.
- */
- if (!priv->heights || priv->heights_length < gtk_menu_get_n_rows (menu))
- return FALSE;
-
- /* when we have a row with only invisible children, its height will
- * be zero, so there's no need to check WIDGET_VISIBLE here
- */
- for (i = 0; i < item_top_attach; i++)
- child_offset += priv->heights[i];
+ GtkAllocation allocation;
- if (offset)
- *offset = child_offset;
- if (height)
- *height = priv->heights[item_top_attach];
+ gtk_widget_get_allocation (menu_item, &allocation);
+ if (allocation.width > 0)
+ {
+ if (offset)
+ *offset = allocation.y + priv->scroll_offset;
+ if (height)
+ *height = allocation.height;
+ return TRUE;
+ }
- return TRUE;
+ return FALSE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]