From a197b202b800845cb57d87cb0d69356aed873df5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 21 Mar 2020 18:28:57 -0400 Subject: [PATCH 1/4] places sidebar: Fix the popovers We need to check-resize the popovers. --- gtk/gtkplacessidebar.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index f62569b5f6..cdcffab742 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -2396,7 +2396,11 @@ show_rename_popover (GtkSidebarRow *row) sidebar->rename_uri = g_strdup (uri); gtk_editable_set_text (GTK_EDITABLE (sidebar->rename_entry), name); + g_object_ref (sidebar->rename_popover); + gtk_widget_unparent (sidebar->rename_popover); gtk_widget_set_parent (sidebar->rename_popover, GTK_WIDGET (row)); + g_object_unref (sidebar->rename_popover); + setup_popover_shadowing (sidebar->rename_popover); gtk_popover_popup (GTK_POPOVER (sidebar->rename_popover)); @@ -4084,6 +4088,9 @@ gtk_places_sidebar_size_allocate (GtkWidget *widget, &(GtkAllocation) { 0, 0, width, height }, baseline); + if (sidebar->popover) + gtk_native_check_resize (GTK_NATIVE (sidebar->popover)); + if (sidebar->rename_popover) gtk_native_check_resize (GTK_NATIVE (sidebar->rename_popover)); } From 6555a2f661aca9043eab05746f6c64792352c581 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 21 Mar 2020 19:32:08 -0400 Subject: [PATCH 2/4] filechooser: Fix the new folder popover We were listening for change notification on a no-longer-existing property. --- gtk/ui/gtkfilechooserwidget.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui index ff7ad061fd..5849701d9a 100644 --- a/gtk/ui/gtkfilechooserwidget.ui +++ b/gtk/ui/gtkfilechooserwidget.ui @@ -63,7 +63,6 @@ Create Folder new_folder_popover folder-new-symbolic - @@ -382,6 +381,7 @@ + 10 From 90197240d3d7988284a0f7550366fb04686cabef Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 21 Mar 2020 20:00:15 -0400 Subject: [PATCH 3/4] filechooser: Fix the file list popover Make this popover work again. --- gtk/gtkfilechooserwidget.c | 57 +++++++++++++++++++--------------- gtk/ui/gtkfilechooserwidget.ui | 1 - 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index c2c852a134..0137ae5e3d 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -85,6 +85,7 @@ #include "gtkbinlayout.h" #include "gtkwidgetprivate.h" #include "gtkpopovermenuprivate.h" +#include "gtknative.h" #include @@ -2036,7 +2037,7 @@ file_list_build_popover (GtkFileChooserWidget *impl) g_object_unref (section); priv->browse_files_popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu)); - gtk_widget_set_parent (priv->browse_files_popover, priv->browse_files_tree_view); + gtk_widget_set_parent (priv->browse_files_popover, GTK_WIDGET (impl)); g_object_unref (menu); } @@ -2113,7 +2114,12 @@ file_list_show_popover (GtkFileChooserWidget *impl, path = list->data; gtk_tree_view_get_cell_area (GTK_TREE_VIEW (priv->browse_files_tree_view), path, NULL, &rect); gtk_tree_view_convert_bin_window_to_widget_coords (GTK_TREE_VIEW (priv->browse_files_tree_view), - rect.x, rect.y, &rect.x, &rect.y); + rect.x, rect.y, + &rect.x, &rect.y); + gtk_widget_translate_coordinates (priv->browse_files_tree_view, + GTK_WIDGET (impl), + rect.x, rect.y, + &rect.x, &rect.y); rect.x = CLAMP (x - 20, 0, bounds.size.width - 40); rect.width = 40; @@ -2132,25 +2138,6 @@ file_list_show_popover (GtkFileChooserWidget *impl, gtk_popover_popup (GTK_POPOVER (priv->browse_files_popover)); } -/* Callback used for the GtkWidget::popup-menu signal of the file list */ -static gboolean -list_popup_menu_cb (GtkWidget *widget, - GtkFileChooserWidget *impl) -{ - GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl); - graphene_rect_t bounds; - - if (gtk_widget_compute_bounds (priv->browse_files_tree_view, - priv->browse_files_tree_view, - &bounds)) - { - file_list_show_popover (impl, 0.5 * bounds.size.width, 0.5 * bounds.size.height); - return TRUE; - } - - return FALSE; -} - /* Callback used when a button is pressed on the file list. We trap button 3 to * bring up a popup menu. */ @@ -2179,12 +2166,17 @@ click_cb (GtkGesture *gesture, double y, GtkFileChooserWidget *impl) { + GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl); PopoverData *pd; + int xx, yy; pd = g_new (PopoverData, 1); pd->impl = impl; - pd->x = x; - pd->y = y; + gtk_widget_translate_coordinates (priv->browse_files_tree_view, + GTK_WIDGET (impl), + x, y, &xx, &yy); + pd->x = xx; + pd->y = yy; g_idle_add (file_list_show_popover_in_idle, pd); } @@ -7475,6 +7467,20 @@ add_normal_and_shifted_binding (GtkBindingSet *binding_set, signal_name, 0); } +static void +gtk_file_chooser_widget_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) +{ + GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (widget); + GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl); + + GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->size_allocate (widget, width, height, baseline); + if (priv->browse_files_popover) + gtk_native_check_resize (GTK_NATIVE (priv->browse_files_popover)); +} + static void gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class) { @@ -7497,6 +7503,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class) widget_class->root = gtk_file_chooser_widget_root; widget_class->unroot = gtk_file_chooser_widget_unroot; widget_class->css_changed = gtk_file_chooser_widget_css_changed; + widget_class->size_allocate = gtk_file_chooser_widget_size_allocate; /* * Signals @@ -7893,7 +7900,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class) gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, box); /* And a *lot* of callbacks to bind ... */ - gtk_widget_class_bind_template_callback (widget_class, list_popup_menu_cb); gtk_widget_class_bind_template_callback (widget_class, file_list_query_tooltip_cb); gtk_widget_class_bind_template_callback (widget_class, list_row_activated); gtk_widget_class_bind_template_callback (widget_class, list_selection_changed); @@ -7984,7 +7990,8 @@ post_process_ui (GtkFileChooserWidget *impl) g_action_map_add_action_entries (G_ACTION_MAP (priv->item_actions), entries, G_N_ELEMENTS (entries), impl); - gtk_widget_insert_action_group (GTK_WIDGET (priv->browse_files_tree_view), "item", + gtk_widget_insert_action_group (GTK_WIDGET (impl), + "item", priv->item_actions); gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (priv->search_entry), priv->search_entry); diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui index 5849701d9a..cb2a8b4c7b 100644 --- a/gtk/ui/gtkfilechooserwidget.ui +++ b/gtk/ui/gtkfilechooserwidget.ui @@ -164,7 +164,6 @@ - From 95209290c464fca78a6fbe01381b7ec189e00cb8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 21 Mar 2020 20:14:23 -0400 Subject: [PATCH 4/4] file chooser: Fix the rename file popover Make this popover work again by attaching it to the file chooser itself. --- gtk/gtkfilechooserwidget.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 0137ae5e3d..28bd54a9cd 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -1536,7 +1536,12 @@ rename_selected_cb (GtkTreeModel *model, path, priv->list_name_column, &rect); gtk_tree_view_convert_bin_window_to_widget_coords (GTK_TREE_VIEW (priv->browse_files_tree_view), - rect.x, rect.y, &rect.x, &rect.y); + rect.x, rect.y, + &rect.x, &rect.y); + gtk_widget_translate_coordinates (priv->browse_files_tree_view, + GTK_WIDGET (impl), + rect.x, rect.y, + &rect.x, &rect.y); filename = g_file_get_basename (priv->rename_file_source_file); gtk_editable_set_text (GTK_EDITABLE (priv->rename_file_name_entry), filename); @@ -7479,6 +7484,8 @@ gtk_file_chooser_widget_size_allocate (GtkWidget *widget, GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->size_allocate (widget, width, height, baseline); if (priv->browse_files_popover) gtk_native_check_resize (GTK_NATIVE (priv->browse_files_popover)); + if (priv->rename_file_popover) + gtk_native_check_resize (GTK_NATIVE (priv->rename_file_popover)); } static void @@ -7995,6 +8002,8 @@ post_process_ui (GtkFileChooserWidget *impl) priv->item_actions); gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (priv->search_entry), priv->search_entry); + + gtk_widget_set_parent (priv->rename_file_popover, GTK_WIDGET (impl)); } void