From 489e77d814f2ce449e87ba61590eb9ca9bd711bc Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Tue, 9 Nov 2004 20:32:01 +0000 Subject: Better positioning for the context menu popup in a treeview. Patch by 2004-11-09 Christian Persch * lib/ephy-gui.c: (ephy_gui_menu_position_tree_selection): Better positioning for the context menu popup in a treeview. Patch by Crispin Flowerday. Remove obsolete global variables. --- lib/ephy-gui.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c index 2e2d355c1..ae389b01f 100644 --- a/lib/ephy-gui.c +++ b/lib/ephy-gui.c @@ -36,10 +36,6 @@ #include #include -/* Styles for tab labels */ -GtkStyle *loading_text_style = NULL; -GtkStyle *new_text_style = NULL; - void ephy_gui_sanitise_popup_position (GtkMenu *menu, GtkWidget *widget, @@ -76,12 +72,17 @@ ephy_gui_menu_position_tree_selection (GtkMenu *menu, GtkTreeView *tree_view = GTK_TREE_VIEW (user_data); GtkWidget *widget = GTK_WIDGET (user_data); GtkRequisition req; + GdkRectangle visible; gtk_widget_size_request (GTK_WIDGET (menu), &req); gdk_window_get_origin (widget->window, x, y); *x += (widget->allocation.width - req.width) / 2; + /* Add on height for the treeview title */ + gtk_tree_view_get_visible_rect (tree_view, &visible); + *y += widget->allocation.height - visible.height; + selection = gtk_tree_view_get_selection (tree_view); selected_rows = gtk_tree_selection_get_selected_rows (selection, &model); if (selected_rows) @@ -91,7 +92,7 @@ ephy_gui_menu_position_tree_selection (GtkMenu *menu, gtk_tree_view_get_cell_area (tree_view, selected_rows->data, NULL, &cell_rect); - *y += CLAMP (cell_rect.y + cell_rect.height, 0, widget->allocation.height); + *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height); g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL); g_list_free (selected_rows); @@ -101,7 +102,7 @@ ephy_gui_menu_position_tree_selection (GtkMenu *menu, } /** - * gul_gui_menu_position_under_widget: + * ephy_gui_menu_position_under_widget: */ void ephy_gui_menu_position_under_widget (GtkMenu *menu, -- cgit v1.2.3