diff options
-rw-r--r-- | src/nautilus-application.c | 20 | ||||
-rw-r--r-- | src/nautilus-gtk4-helpers.c | 18 | ||||
-rw-r--r-- | src/nautilus-gtk4-helpers.h | 7 |
3 files changed, 35 insertions, 10 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 348dae188..76ac83fea 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -1121,11 +1121,11 @@ theme_changed (GtkSettings *settings) static GtkCssProvider *provider = NULL; static GtkCssProvider *permanent_provider = NULL; gchar *theme; - GdkScreen *screen; + GdkDisplay *display; GFile *file; g_object_get (settings, "gtk-theme-name", &theme, NULL); - screen = gdk_screen_get_default (); + display = gdk_display_get_default (); /* CSS that themes can override */ if (g_str_equal (theme, "Adwaita") || g_str_equal (theme, "Adwaita-dark")) @@ -1138,14 +1138,14 @@ theme_changed (GtkSettings *settings) g_object_unref (file); } - gtk_style_context_add_provider_for_screen (screen, - GTK_STYLE_PROVIDER (provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_style_context_add_provider_for_display (display, + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } else if (provider != NULL) { - gtk_style_context_remove_provider_for_screen (screen, - GTK_STYLE_PROVIDER (provider)); + gtk_style_context_remove_provider_for_display (display, + GTK_STYLE_PROVIDER (provider)); g_clear_object (&provider); } @@ -1159,9 +1159,9 @@ theme_changed (GtkSettings *settings) * undefined and gtk happens to prefer the provider that got added last. * Use a higher priority here to avoid this problem. */ - gtk_style_context_add_provider_for_screen (screen, - GTK_STYLE_PROVIDER (permanent_provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1); + gtk_style_context_add_provider_for_display (display, + GTK_STYLE_PROVIDER (permanent_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1); g_object_unref (file); } diff --git a/src/nautilus-gtk4-helpers.c b/src/nautilus-gtk4-helpers.c index cd89a4423..445427943 100644 --- a/src/nautilus-gtk4-helpers.c +++ b/src/nautilus-gtk4-helpers.c @@ -114,3 +114,21 @@ gtk_window_set_display (GtkWindow *window, gtk_window_set_screen (window, gdk_display_get_default_screen (display)); } + +void +gtk_style_context_add_provider_for_display (GdkDisplay *display, + GtkStyleProvider *provider, + guint priority) +{ + gtk_style_context_add_provider_for_screen (gdk_display_get_default_screen (display), + provider, + priority); +} + +void +gtk_style_context_remove_provider_for_display (GdkDisplay *display, + GtkStyleProvider *provider) +{ + gtk_style_context_remove_provider_for_screen (gdk_display_get_default_screen (display), + provider); +} diff --git a/src/nautilus-gtk4-helpers.h b/src/nautilus-gtk4-helpers.h index 2e8e4817b..e5edb55a1 100644 --- a/src/nautilus-gtk4-helpers.h +++ b/src/nautilus-gtk4-helpers.h @@ -28,6 +28,13 @@ void gtk_revealer_set_child (GtkRevealer *revealer, GtkWidget *gtk_widget_get_first_child (GtkWidget *widget); + +void gtk_style_context_add_provider_for_display (GdkDisplay *display, + GtkStyleProvider *provider, + guint priority); +void gtk_style_context_remove_provider_for_display (GdkDisplay *display, + GtkStyleProvider *provider); + #define GTK_ROOT(root) ((GtkRoot *) GTK_WINDOW (root)) typedef GtkWindow GtkRoot; GdkDisplay *gtk_root_get_display (GtkRoot *root); |