[nautilus] rename-file-popover-controller: Set parent only on creation



commit d6982dba131959a504c73d3037bdf48c0ec17df4
Author: Corey Berla <corey berla me>
Date:   Mon Jul 25 10:29:01 2022 -0700

    rename-file-popover-controller: Set parent only on creation
    
    We are attempting to reset the parent to the view every time
    the rename popover shows.  This triggers warnings because the
    popover already has a parent.  There's no reason to do this because
    we are setting the parent to the view over and over again.
    Since the popover and view have the same lifecycle, set the parent
    on creation.

 src/nautilus-files-view.c                     | 5 ++---
 src/nautilus-rename-file-popover-controller.c | 8 ++++----
 src/nautilus-rename-file-popover-controller.h | 5 ++---
 3 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 1ba862c7a..52e9e6ac4 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -2040,8 +2040,7 @@ nautilus_files_view_rename_file_popover_new (NautilusFilesView *view,
 
     nautilus_rename_file_popover_controller_show_for_file (priv->rename_file_controller,
                                                            target_file,
-                                                           pointing_to,
-                                                           GTK_WIDGET (view));
+                                                           pointing_to);
 
     priv->name_accepted_handler_id = g_signal_connect (priv->rename_file_controller,
                                                        "name-accepted",
@@ -9702,7 +9701,7 @@ nautilus_files_view_init (NautilusFilesView *view)
 
     priv->starred_cancellable = g_cancellable_new ();
 
-    priv->rename_file_controller = nautilus_rename_file_popover_controller_new ();
+    priv->rename_file_controller = nautilus_rename_file_popover_controller_new (GTK_WIDGET (view));
 
     nautilus_profile_end (NULL);
 }
diff --git a/src/nautilus-rename-file-popover-controller.c b/src/nautilus-rename-file-popover-controller.c
index b5fdbc48c..0f3b3291e 100644
--- a/src/nautilus-rename-file-popover-controller.c
+++ b/src/nautilus-rename-file-popover-controller.c
@@ -272,7 +272,7 @@ target_file_on_changed (NautilusFile *file,
 }
 
 NautilusRenameFilePopoverController *
-nautilus_rename_file_popover_controller_new (void)
+nautilus_rename_file_popover_controller_new (GtkWidget *relative_to)
 {
     NautilusRenameFilePopoverController *self;
     g_autoptr (GtkBuilder) builder = NULL;
@@ -304,6 +304,8 @@ nautilus_rename_file_popover_controller_new (void)
 
     gtk_popover_set_default_widget (GTK_POPOVER (rename_file_popover), name_entry);
 
+    gtk_widget_set_parent (rename_file_popover, relative_to);
+
     return self;
 }
 
@@ -318,8 +320,7 @@ nautilus_rename_file_popover_controller_get_target_file (NautilusRenameFilePopov
 void
 nautilus_rename_file_popover_controller_show_for_file   (NautilusRenameFilePopoverController *self,
                                                          NautilusFile                        *target_file,
-                                                         GdkRectangle                        *pointing_to,
-                                                         GtkWidget                           *relative_to)
+                                                         GdkRectangle                        *pointing_to)
 {
     g_autoptr (NautilusDirectory) containing_directory = NULL;
     GtkEventController *controller;
@@ -374,7 +375,6 @@ nautilus_rename_file_popover_controller_show_for_file   (NautilusRenameFilePopov
     gtk_editable_set_text (GTK_EDITABLE (self->name_entry), edit_name);
 
     gtk_popover_set_pointing_to (GTK_POPOVER (self->rename_file_popover), pointing_to);
-    gtk_widget_set_parent (self->rename_file_popover, relative_to);
 
     gtk_popover_popup (GTK_POPOVER (self->rename_file_popover));
 
diff --git a/src/nautilus-rename-file-popover-controller.h b/src/nautilus-rename-file-popover-controller.h
index c4627bce5..d9b229ee2 100644
--- a/src/nautilus-rename-file-popover-controller.h
+++ b/src/nautilus-rename-file-popover-controller.h
@@ -28,11 +28,10 @@
 #define NAUTILUS_TYPE_RENAME_FILE_POPOVER_CONTROLLER nautilus_rename_file_popover_controller_get_type ()
 G_DECLARE_FINAL_TYPE (NautilusRenameFilePopoverController, nautilus_rename_file_popover_controller, 
NAUTILUS, RENAME_FILE_POPOVER_CONTROLLER, NautilusFileNameWidgetController)
 
-NautilusRenameFilePopoverController * nautilus_rename_file_popover_controller_new (void);
+NautilusRenameFilePopoverController * nautilus_rename_file_popover_controller_new (GtkWidget *relative_to);
 
 NautilusFile * nautilus_rename_file_popover_controller_get_target_file (NautilusRenameFilePopoverController 
*controller);
 
 void           nautilus_rename_file_popover_controller_show_for_file   (NautilusRenameFilePopoverController 
*controller,
                                                                         NautilusFile                        
*target_file,
-                                                                        GdkRectangle                        
*pointing_to,
-                                                                        GtkWidget                           
*relative_to);
+                                                                        GdkRectangle                        
*pointing_to);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]