forked from AuroraMiddleware/gtk
menu: Simplify function
No need to do complicated math when we can just look at the allocation.
This commit is contained in:
parent
e702a33432
commit
d971c4e69d
@ -3521,32 +3521,21 @@ 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;
|
||||
|
||||
gtk_widget_get_allocation (menu_item, &allocation);
|
||||
if (allocation.width > 0)
|
||||
{
|
||||
if (offset)
|
||||
*offset = child_offset;
|
||||
*offset = allocation.y + priv->scroll_offset;
|
||||
if (height)
|
||||
*height = priv->heights[item_top_attach];
|
||||
|
||||
*height = allocation.height;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
|
||||
GtkWidget *menu_item)
|
||||
|
Loading…
Reference in New Issue
Block a user