[nautilus/wip/antoniof/gtk4-preparation-popovers: 20/45] application: Stop using GdkScreen for style providers




commit 72769f9f62170ade589d581fabdb6c8ad4c02035
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 0240cedf6..9fd931a4b 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 a68363cb8..6dde5152f 100644
--- a/src/nautilus-gtk4-helpers.c
+++ b/src/nautilus-gtk4-helpers.c
@@ -105,3 +105,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 dfd32a65d..52038d360 100644
--- a/src/nautilus-gtk4-helpers.h
+++ b/src/nautilus-gtk4-helpers.h
@@ -26,6 +26,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);


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