From: Matthias Clasen Date: Wed, 12 Oct 2022 04:24:15 +0000 (-0400) Subject: filechooser: Some work on popup menus X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~143^2~18 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8ec9c3fdc6c6107bcb456b29717142f24bb3e230;p=gtk4.git filechooser: Some work on popup menus This is a start towards placing menus properly. We once again center keyboard-triggered menus on the file list. --- diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 7084c99705..703dbe5a24 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -1920,17 +1920,11 @@ file_list_show_popover (GtkFileChooserWidget *impl, double y) { GdkRectangle rect; - graphene_rect_t bounds; - - if (!gtk_widget_compute_bounds (impl->browse_files_column_view, - impl->browse_files_column_view, - &bounds)) - return; file_list_update_popover (impl); /* TODO: figure out popover position */ - rect = (GdkRectangle) { 0, 0, 0, 0 }; + rect = (GdkRectangle) { (int) x, (int) y, 1, 1 }; gtk_popover_set_pointing_to (GTK_POPOVER (impl->browse_files_popover), &rect); gtk_popover_popup (GTK_POPOVER (impl->browse_files_popover)); @@ -1944,15 +1938,16 @@ list_popup_menu_cb (GtkWidget *widget, GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (user_data); graphene_rect_t bounds; - if (gtk_widget_compute_bounds (impl->browse_files_column_view, - impl->browse_files_column_view, - &bounds)) - { - file_list_show_popover (impl, 0.5 * bounds.size.width, 0.5 * bounds.size.height); - return TRUE; - } + if (!gtk_widget_compute_bounds (impl->browse_files_column_view, + GTK_WIDGET (impl), + &bounds)) + return FALSE; - return FALSE; + file_list_show_popover (impl, + bounds.origin.x + bounds.size.width / 2, + bounds.origin.y + bounds.size.height / 2); + + return TRUE; } static void