[nautilus/wip/antoniof/use-cached-templates-menu-model: 4/5] files-view: Only refresh Scripts menu if needed
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/use-cached-templates-menu-model: 4/5] files-view: Only refresh Scripts menu if needed
- Date: Tue, 26 Oct 2021 16:45:03 +0000 (UTC)
commit e29ead7a2641812f2fd7a6133b413b26b780cf55
Author: António Fernandes <antoniof gnome org>
Date: Tue Oct 26 16:41:26 2021 +0100
files-view: Only refresh Scripts menu if needed
Now that the scripts menu is cached, we can do the same optimization as
done for templates two commits ago.
src/nautilus-files-view.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 7dcd15020..900c2608a 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -183,6 +183,7 @@ typedef struct
GList *scripts_directory_list;
GList *templates_directory_list;
+ gboolean scripts_menu_updated;
gboolean templates_menu_updated;
guint display_selection_idle_id;
@@ -3034,6 +3035,7 @@ scripts_added_or_changed_callback (NautilusDirectory *directory,
view = NAUTILUS_FILES_VIEW (callback_data);
priv = nautilus_files_view_get_instance_private (view);
+ priv->scripts_menu_updated = FALSE;
if (priv->active)
{
schedule_update_context_menus (view);
@@ -5610,16 +5612,8 @@ update_scripts_menu (NautilusFilesView *view,
directory = nautilus_directory_get_by_uri (scripts_directory_uri);
submenu = update_directory_in_scripts_menu (view, directory);
g_set_object (&priv->scripts_menu, G_MENU_MODEL (submenu));
- if (submenu != NULL)
- {
- GObject *object;
-
- object = gtk_builder_get_object (builder, "scripts-submenu-section");
- nautilus_gmenu_set_from_model (G_MENU (object),
- G_MENU_MODEL (submenu));
- g_object_unref (submenu);
- }
+ g_object_unref (submenu);
nautilus_directory_unref (directory);
}
@@ -8063,6 +8057,7 @@ static void
update_selection_menu (NautilusFilesView *view,
GtkBuilder *builder)
{
+ NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
g_autolist (NautilusFile) selection = NULL;
GList *l;
gint selection_count;
@@ -8300,7 +8295,13 @@ update_selection_menu (NautilusFilesView *view,
g_object_unref (menu_item);
}
- update_scripts_menu (view, builder);
+ if (!priv->scripts_menu_updated)
+ {
+ update_scripts_menu (view, builder);
+ priv->scripts_menu_updated = TRUE;
+ }
+ object = gtk_builder_get_object (builder, "scripts-submenu-section");
+ nautilus_gmenu_set_from_model (G_MENU (object), priv->scripts_menu);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]