From 96d542a0d84da4ad6915a7727642490a5c433d4a Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 14 Oct 2022 05:56:47 -0700 Subject: [PATCH 1/2] global-preferences: Update filechooser schema path for gtk4 this solves a bug where nautilus would crash immediately on start if the system lacks a gtk3 installation: ```console $ nautilus (org.gnome.Nautilus): GLib-GIO-ERROR **: Settings schema 'org.gtk.Settings.FileChooser' is not installed ``` gtk renamed this settings schema here: - now that nautilus depends specifically on gtk4, it needs to use that gtk4 settings schemas. --- src/nautilus-global-preferences.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nautilus-global-preferences.c b/src/nautilus-global-preferences.c index fd6d53e081..6bc991908f 100644 --- a/src/nautilus-global-preferences.c +++ b/src/nautilus-global-preferences.c @@ -59,8 +59,8 @@ nautilus_global_preferences_init (void) nautilus_icon_view_preferences = g_settings_new ("org.gnome.nautilus.icon-view"); nautilus_list_view_preferences = g_settings_new ("org.gnome.nautilus.list-view"); /* Some settings such as show hidden files are shared between Nautilus and GTK file chooser */ - gtk_filechooser_preferences = g_settings_new_with_path ("org.gtk.Settings.FileChooser", - "/org/gtk/settings/file-chooser/"); + gtk_filechooser_preferences = g_settings_new_with_path ("org.gtk.gtk4.Settings.FileChooser", + "/org/gtk/gtk4/settings/file-chooser/"); gnome_lockdown_preferences = g_settings_new ("org.gnome.desktop.lockdown"); gnome_interface_preferences = g_settings_new ("org.gnome.desktop.interface"); gnome_privacy_preferences = g_settings_new ("org.gnome.desktop.privacy"); -- GitLab From 52b4daf4396fd3b21755b3a0d1fbf85c3831c6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Sat, 22 Oct 2022 01:16:15 +0100 Subject: [PATCH 2/2] application: Migrate setting values to new gtk schema This preserves previously-set user preferences. --- data/org.gnome.nautilus.gschema.xml | 5 +++++ src/nautilus-application.c | 33 +++++++++++++++++++++++++++++ src/nautilus-global-preferences.h | 3 +++ 3 files changed, 41 insertions(+) diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml index e32cac3e36..cbc3290989 100644 --- a/data/org.gnome.nautilus.gschema.xml +++ b/data/org.gnome.nautilus.gschema.xml @@ -168,6 +168,11 @@ Whether to show hidden files This key is deprecated and ignored. The “show-hidden” key from “org.gtk.Settings.FileChooser” is now used instead. + + false + Whether GTK 4 settings migration happened + Whether settings shared with GtkFileChooser have been migrated from their GTK 3 key to the GTK 4 ones. + 'list-view' What viewer should be used when searching diff --git a/src/nautilus-application.c b/src/nautilus-application.c index c3e5881034..5d8d750b97 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -1133,6 +1133,38 @@ icon_theme_changed_callback (GtkIconTheme *icon_theme, emit_change_signals_for_all_files_in_all_directories (); } +static void +maybe_migrate_gtk_filechooser_preferences (void) +{ + if (!g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_MIGRATED_GTK_SETTINGS)) + { + g_autoptr (GSettingsSchema) schema = NULL; + + /* We don't depend on GTK 3. Check whether its schema is installed. */ + schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), + "org.gtk.Settings.FileChooser", + FALSE); + if (schema != NULL) + { + g_autoptr (GSettings) gtk3_settings = NULL; + + gtk3_settings = g_settings_new_with_path ("org.gtk.Settings.FileChooser", + "/org/gtk/settings/file-chooser/"); + g_settings_set_boolean (gtk_filechooser_preferences, + NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, + g_settings_get_boolean (gtk3_settings, + NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST)); + g_settings_set_boolean (gtk_filechooser_preferences, + NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, + g_settings_get_boolean (gtk3_settings, + NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES)); + } + g_settings_set_boolean (nautilus_preferences, + NAUTILUS_PREFERENCES_MIGRATED_GTK_SETTINGS, + TRUE); + } +} + void nautilus_application_startup_common (NautilusApplication *self) { @@ -1173,6 +1205,7 @@ nautilus_application_startup_common (NautilusApplication *self) if (g_strcmp0 (g_getenv ("RUNNING_TESTS"), "TRUE") != 0) { + maybe_migrate_gtk_filechooser_preferences (); nautilus_tag_manager_maybe_migrate_tracker2_data (priv->tag_manager); } diff --git a/src/nautilus-global-preferences.h b/src/nautilus-global-preferences.h index 5168f383fb..5a73717b30 100644 --- a/src/nautilus-global-preferences.h +++ b/src/nautilus-global-preferences.h @@ -127,6 +127,9 @@ typedef enum /* Full Text Search enabled */ #define NAUTILUS_PREFERENCES_FTS_ENABLED "fts-enabled" +/* Gtk settings migration happened */ +#define NAUTILUS_PREFERENCES_MIGRATED_GTK_SETTINGS "migrated-gtk-settings" + void nautilus_global_preferences_init (void); extern GSettings *nautilus_preferences; -- GitLab