[nautilus/wip/corey/selection-performance: 24/26] files-view: Reorganize real_update_context_menus




commit d0a5619f19ad64db456ceee6ce1b5ca1e06f05b7
Author: Corey Berla <corey berla me>
Date:   Sat Oct 1 08:17:18 2022 -0700

    files-view: Reorganize real_update_context_menus
    
    This doesn't have any functional changes, it is necessary for the
    next commit

 src/nautilus-files-view.c | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 0bd5edd6c..c274174be 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5176,13 +5176,15 @@ build_menu_for_extension_menu_items (NautilusFilesView *view,
 }
 
 static void
-update_extensions_menus (NautilusFilesView *view,
-                         GtkBuilder        *builder)
+update_extensions_menus (NautilusFilesView *view)
 {
     GList *selection_items, *background_items;
     GObject *object;
     g_autoptr (GMenuModel) background_menu = NULL;
     g_autoptr (GMenuModel) selection_menu = NULL;
+    g_autoptr (GtkBuilder) builder = NULL;
+
+    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-files-view-context-menus.ui");
 
     selection_items = get_extension_selection_menu_items (view);
     if (selection_items != NULL)
@@ -7969,11 +7971,11 @@ nautilus_files_view_update_actions_state (NautilusFilesView *view)
 }
 
 static void
-update_selection_menu (NautilusFilesView *view,
-                       GtkBuilder        *builder)
+update_selection_menu (NautilusFilesView *view)
 {
     NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
     g_autolist (NautilusFile) selection = NULL;
+    g_autoptr (GtkBuilder) builder = NULL;
     GList *l;
     gint selection_count;
     gboolean show_app;
@@ -7995,6 +7997,13 @@ update_selection_menu (NautilusFilesView *view,
     gint i;
     GDriveStartStopType start_stop_type;
 
+    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-files-view-context-menus.ui");
+
+    g_clear_object (&priv->selection_menu_model);
+
+    object = gtk_builder_get_object (builder, "selection-menu");
+    priv->selection_menu_model = g_object_ref (G_MENU (object));
+
     selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
     selection_count = g_list_length (selection);
 
@@ -8257,14 +8266,21 @@ update_selection_menu (NautilusFilesView *view,
 }
 
 static void
-update_background_menu (NautilusFilesView *view,
-                        GtkBuilder        *builder)
+update_background_menu (NautilusFilesView *view)
 {
     NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
+    g_autoptr (GtkBuilder) builder = NULL;
     GObject *object;
     gboolean remove_submenu = TRUE;
     gint i;
 
+    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-files-view-context-menus.ui");
+
+    g_clear_object (&priv->background_menu_model);
+
+    object = gtk_builder_get_object (builder, "background-menu");
+    priv->background_menu_model = g_object_ref (G_MENU (object));
+
     if (nautilus_files_view_supports_creating_files (view) &&
         !showing_recent_directory (view) &&
         !showing_starred_directory (view))
@@ -8306,24 +8322,14 @@ static void
 real_update_context_menus (NautilusFilesView *view)
 {
     NautilusFilesViewPrivate *priv;
-    g_autoptr (GtkBuilder) builder = NULL;
-    GObject *object;
 
     priv = nautilus_files_view_get_instance_private (view);
-    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-files-view-context-menus.ui");
 
-    g_clear_object (&priv->background_menu_model);
-    g_clear_object (&priv->selection_menu_model);
 
-    object = gtk_builder_get_object (builder, "background-menu");
-    priv->background_menu_model = g_object_ref (G_MENU (object));
-
-    object = gtk_builder_get_object (builder, "selection-menu");
-    priv->selection_menu_model = g_object_ref (G_MENU (object));
 
-    update_selection_menu (view, builder);
-    update_background_menu (view, builder);
-    update_extensions_menus (view, builder);
+    update_selection_menu (view);
+    update_background_menu (view);
+    update_extensions_menus (view);
 
     nautilus_files_view_update_actions_state (view);
 }


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