[gnome-software: 16/110] Adapt to GtkCssProvider API changes




commit 44aec19ab9de11518dee70ca1bcedbe91caaad1c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Aug 21 14:28:26 2021 -0300

    Adapt to GtkCssProvider API changes
    
    GTK4 uses GdkDisplay instead of GdkScreen, so gdk_screen_get_default()
    becomes gdk_display_get_default(). Also, GtkCssSection has start and
    end *locations* instead of lines, so switch to that too.

 src/gs-application.c     |  8 ++++----
 src/gs-common.c          | 11 +++++++----
 src/gs-css.c             | 17 ++++++++++-------
 src/gs-progress-button.c |  2 +-
 4 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 78102cb10..3344887eb 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -255,7 +255,7 @@ theme_changed (GtkSettings *settings, GParamSpec *pspec, GsApplication *app)
        } else {
                file = g_file_new_for_uri ("resource:///org/gnome/Software/gtk-style.css");
        }
-       gtk_css_provider_load_from_file (app->provider, file, NULL);
+       gtk_css_provider_load_from_file (app->provider, file);
 }
 
 static void
@@ -277,9 +277,9 @@ gs_application_initialize_ui (GsApplication *app)
 
        /* get CSS */
        app->provider = gtk_css_provider_new ();
-       gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
-                                                  GTK_STYLE_PROVIDER (app->provider),
-                                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+       gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+                                                   GTK_STYLE_PROVIDER (app->provider),
+                                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
        g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name",
                          G_CALLBACK (theme_changed), app);
diff --git a/src/gs-common.c b/src/gs-common.c
index 583c8c1f6..f5339da8a 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -329,9 +329,12 @@ gs_utils_widget_css_parsing_error_cb (GtkCssProvider *provider,
                                      GError *error,
                                      gpointer user_data)
 {
-       g_warning ("CSS parse error %u:%u: %s",
-                  gtk_css_section_get_start_line (section),
-                  gtk_css_section_get_start_position (section),
+       const GtkCssLocation *start_location;
+
+       start_location = gtk_css_section_get_start_location (section);
+       g_warning ("CSS parse error %lu:%lu: %s",
+                  start_location->lines + 1,
+                  start_location->line_chars,
                   error->message);
 }
 
@@ -445,7 +448,7 @@ gs_utils_widget_set_css (GtkWidget *widget, GtkCssProvider **provider, const gch
        gtk_style_context_add_class (context, class_name);
 
        /* set up custom provider and store on the widget */
-       gtk_css_provider_load_from_data (*provider, str->str, -1, NULL);
+       gtk_css_provider_load_from_data (*provider, str->str, -1);
        gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (*provider),
                                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
diff --git a/src/gs-css.c b/src/gs-css.c
index 0f9564319..73b546caf 100644
--- a/src/gs-css.c
+++ b/src/gs-css.c
@@ -163,9 +163,12 @@ _css_parsing_error_cb (GtkCssProvider *provider,
 {
        GError **error_parse = (GError **) user_data;
        if (*error_parse != NULL) {
-               g_warning ("ignoring parse error %u:%u: %s",
-                          gtk_css_section_get_start_line (section),
-                          gtk_css_section_get_start_position (section),
+               const GtkCssLocation *start_location;
+
+               start_location = gtk_css_section_get_start_location (section);
+               g_warning ("ignoring parse error %lu:%lu: %s",
+                          start_location->lines + 1,
+                          start_location->line_chars,
                           error->message);
                return;
        }
@@ -203,10 +206,10 @@ gs_css_validate_part (GsCss *self, const gchar *markup, GError **error)
        provider = gtk_css_provider_new ();
        g_signal_connect (provider, "parsing-error",
                          G_CALLBACK (_css_parsing_error_cb), &error_parse);
-       gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
-                                                  GTK_STYLE_PROVIDER (provider),
-                                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-       gtk_css_provider_load_from_data (provider, str->str, -1, NULL);
+       gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+                                                   GTK_STYLE_PROVIDER (provider),
+                                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+       gtk_css_provider_load_from_data (provider, str->str, -1);
        if (error_parse != NULL) {
                if (error != NULL)
                        *error = g_error_copy (error_parse);
diff --git a/src/gs-progress-button.c b/src/gs-progress-button.c
index 4f084d0e4..d48c055a0 100644
--- a/src/gs-progress-button.c
+++ b/src/gs-progress-button.c
@@ -54,7 +54,7 @@ gs_progress_button_set_progress (GsProgressButton *button, guint percentage)
                css = tmp;
        }
 
-       gtk_css_provider_load_from_data (button->css_provider, css, -1, NULL);
+       gtk_css_provider_load_from_data (button->css_provider, css, -1);
 }
 
 void


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