[nautilus/gtk4-preparation-trunk: 102/120] application: Stop using GdkScreen for style providers




commit 25cfd5f3770bd7b31f4d0d99ae698a8e00edb92d
Author: António Fernandes <antoniof gnome org>
Date:   Thu Dec 16 00:31:20 2021 +0000

    application: Stop using GdkScreen for style providers
    
    GdkScreen is going away with GTK 4. Use wrappers for GTK 4 API which
    takes GdkDisplay instead.

 src/nautilus-application.c  | 20 ++++++++++----------
 src/nautilus-gtk4-helpers.c | 18 ++++++++++++++++++
 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 ac605fa04..e254c6513 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -1120,11 +1120,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"))
@@ -1137,14 +1137,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);
     }
 
@@ -1158,9 +1158,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 c8f35fc3f..8d4ae4c2a 100644
--- a/src/nautilus-gtk4-helpers.c
+++ b/src/nautilus-gtk4-helpers.c
@@ -149,3 +149,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 6bc991ac9..f712758f0 100644
--- a/src/nautilus-gtk4-helpers.h
+++ b/src/nautilus-gtk4-helpers.h
@@ -38,6 +38,13 @@ void gtk_check_button_set_active   (GtkCheckButton    *button,
 gboolean gtk_check_button_get_active (GtkCheckButton  *button);
 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);


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