[gtk+] Changed combo box's menu position function to use child menu item's allocation instead of a complex
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Changed combo box's menu position function to use child menu item's allocation instead of a complex
- Date: Fri, 20 Aug 2010 23:44:42 +0000 (UTC)
commit 005e8a6c2f1751ed37ea9b8bae2f2d5b6f2c5e06
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Fri Aug 20 19:24:54 2010 -0400
Changed combo box's menu position function to use child menu
item's allocation instead of a complex calculation to guess
it's height for width.
gtk/gtkcombobox.c | 32 ++++++++------------------------
1 files changed, 8 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 6dd236b..57a439f 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1565,12 +1565,9 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
GtkWidget *active;
GtkWidget *child;
GtkWidget *widget;
- GtkRequisition requisition;
+ GtkAllocation child_allocation;
GList *children;
- guint horizontal_padding, border_width;
gint screen_width;
- gint menu_item_avail_width;
- gint min_item_height;
gint menu_xpos;
gint menu_ypos;
gint menu_width;
@@ -1578,30 +1575,17 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
combo_box = GTK_COMBO_BOX (user_data);
widget = GTK_WIDGET (combo_box);
- gtk_widget_style_get (GTK_WIDGET (menu),
- "horizontal-padding", &horizontal_padding,
- NULL);
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
-
- /* Get the minimum height for minimum width of the menu */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu), &requisition, NULL);
- menu_width = requisition.width;
-
- /* Get the size for the height-for-width menu-item requests */
- menu_item_avail_width =
- menu_width - (border_width + horizontal_padding + widget->style->xthickness) * 2;
-
active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
menu_xpos = widget->allocation.x;
menu_ypos = widget->allocation.y + widget->allocation.height / 2 - 2;
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (menu), &menu_width, NULL);
+
if (active != NULL)
{
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (active),
- menu_item_avail_width, &min_item_height, NULL);
- menu_ypos -= min_item_height / 2;
+ gtk_widget_get_allocation (active, &child_allocation);
+ menu_ypos -= child_allocation.height / 2;
}
children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
@@ -1614,9 +1598,9 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
if (gtk_widget_get_visible (child))
{
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child),
- menu_item_avail_width, &min_item_height, NULL);
- menu_ypos -= min_item_height;
+ gtk_widget_get_allocation (child, &child_allocation);
+
+ menu_ypos -= child_allocation.height;
}
children = children->next;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]