From 1ad4c04b2a17dd84b3929a6c70b2712c31dff99b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 16 May 2023 21:22:01 +0100 Subject: [PATCH] Replace deprecated CSS loading API Use gtk_css_provider_load_from_string() when loading CSS from C strings. --- examples/plugman.c | 4 ++-- tests/animated-revealing.c | 2 +- tests/testadjustsize.c | 6 +++--- tests/testborderdrawing.c | 2 +- tests/testdndresize.c | 11 +++++------ tests/testentryicons.c | 8 ++++---- tests/testhover.c | 5 ++--- tests/testlevelbar.c | 2 +- tests/testoutsetshadowdrawing.c | 2 +- tests/testoverlaystyleclass.c | 15 +++++++-------- tests/testpopup.c | 2 +- 11 files changed, 28 insertions(+), 31 deletions(-) diff --git a/examples/plugman.c b/examples/plugman.c index 8fb19d7b91..8644bbaace 100644 --- a/examples/plugman.c +++ b/examples/plugman.c @@ -57,7 +57,7 @@ window_paste (GSimpleAction *action, { GtkWindow *window = GTK_WINDOW (user_data); GtkTextView *text = g_object_get_data ((GObject*)window, "plugman-text"); - + gtk_text_buffer_paste_clipboard (gtk_text_view_get_buffer (text), gtk_widget_get_clipboard (GTK_WIDGET (text)), NULL, @@ -221,7 +221,7 @@ plugin_action (GAction *action, g_message ("Color: %s", g_action_get_name (action)); css_provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (css_provider, css_to_load, -1); + gtk_css_provider_load_from_string (css_provider, css_to_load); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/tests/animated-revealing.c b/tests/animated-revealing.c index 424c04ad8b..7d9f158625 100644 --- a/tests/animated-revealing.c +++ b/tests/animated-revealing.c @@ -66,7 +66,7 @@ main(int argc, char **argv) gtk_revealer_set_child (GTK_REVEALER (revealer), grid); cssprovider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (cssprovider, "* { padding: 2px; text-shadow: 5px 5px 2px grey; }", -1); + gtk_css_provider_load_from_string (cssprovider, "* { padding: 2px; text-shadow: 5px 5px 2px grey; }"); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (cssprovider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/tests/testadjustsize.c b/tests/testadjustsize.c index 27101ed490..ca2eb2f049 100644 --- a/tests/testadjustsize.c +++ b/tests/testadjustsize.c @@ -360,15 +360,15 @@ main (int argc, char *argv[]) gtk_init (); provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, + gtk_css_provider_load_from_string (provider, ".black-bg { background-color: black; }" ".red-bg { background-color: red; }" - ".blue-bg { background-color: blue; }", -1); + ".blue-bg { background-color: blue; }"); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); - + if (g_getenv ("RTL")) gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); diff --git a/tests/testborderdrawing.c b/tests/testborderdrawing.c index 661d2481c9..e9d5c26b37 100644 --- a/tests/testborderdrawing.c +++ b/tests/testborderdrawing.c @@ -101,7 +101,7 @@ main (int argc, char **argv) gtk_init (); provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, css, -1); + gtk_css_provider_load_from_string (provider, css); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/tests/testdndresize.c b/tests/testdndresize.c index 5c78bf5606..d11b707787 100644 --- a/tests/testdndresize.c +++ b/tests/testdndresize.c @@ -161,12 +161,11 @@ main (int argc, char *argv[]) gtk_init (); provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, - ".dnd {" - "background-color: red;" - "border-top: 10px solid rebeccapurple;" - "}", - -1); + gtk_css_provider_load_from_string (provider, + ".dnd {" + "background-color: red;" + "border-top: 10px solid rebeccapurple;" + "}"); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/tests/testentryicons.c b/tests/testentryicons.c index 25d640f758..7c6d448a98 100644 --- a/tests/testentryicons.c +++ b/tests/testentryicons.c @@ -159,18 +159,18 @@ main (int argc, char **argv) gtk_grid_attach (GTK_GRID (grid), entry, 1, 1, 1, 1); gtk_editable_set_text (GTK_EDITABLE (entry), "ā€¸Right-to-left"); gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL); - + gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, "document-save-symbolic"); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, "Save a file"); - + content = gdk_content_provider_new_typed (G_TYPE_STRING, "Amazing"); gtk_entry_set_icon_drag_source (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, - content, GDK_ACTION_COPY); + content, GDK_ACTION_COPY); g_object_unref (content); /* @@ -298,7 +298,7 @@ main (int argc, char **argv) GtkCssProvider *provider; provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, cssdata, -1); + gtk_css_provider_load_from_string (provider, cssdata); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800); gtk_window_present (GTK_WINDOW (window)); diff --git a/tests/testhover.c b/tests/testhover.c index a139919221..46b85f63cc 100644 --- a/tests/testhover.c +++ b/tests/testhover.c @@ -265,7 +265,7 @@ main (int argc, char *argv[]) gtk_init (); provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, + gtk_css_provider_load_from_string (provider, ":hover {" " box-shadow: inset 0px 0px 0px 1px red;" " }" @@ -274,8 +274,7 @@ main (int argc, char *argv[]) " }" " window :not(.title):hover * {" " background: goldenrod;" - " }", - -1); + " }"); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800); g_object_unref (provider); diff --git a/tests/testlevelbar.c b/tests/testlevelbar.c index e3ace27e3d..27058cedb5 100644 --- a/tests/testlevelbar.c +++ b/tests/testlevelbar.c @@ -34,7 +34,7 @@ add_custom_css (void) "}"; provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, data, -1); + gtk_css_provider_load_from_string (provider, data); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/tests/testoutsetshadowdrawing.c b/tests/testoutsetshadowdrawing.c index ad79a9a25f..a52d715598 100644 --- a/tests/testoutsetshadowdrawing.c +++ b/tests/testoutsetshadowdrawing.c @@ -99,7 +99,7 @@ main (int argc, char **argv) gtk_init (); provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, css, -1); + gtk_css_provider_load_from_string (provider, css); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/tests/testoverlaystyleclass.c b/tests/testoverlaystyleclass.c index 747783972a..1c4e40ff43 100644 --- a/tests/testoverlaystyleclass.c +++ b/tests/testoverlaystyleclass.c @@ -22,7 +22,7 @@ overlay_get_child_position (GtkOverlay *overlay, return TRUE; } -int +int main (int argc, char *argv[]) { GtkWidget *win, *overlay, *grid, *main_child, *child, *label, *sw; @@ -32,13 +32,12 @@ main (int argc, char *argv[]) gtk_init (); provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, - "label { border: 3px solid black; border-radius: 5px; padding: 2px; }" - ".top { border-top-style: none; border-top-right-radius: 0px; border-top-left-radius: 0px; }" - ".bottom { border-bottom-style: none; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; }" - ".left { border-left-style: none; border-top-left-radius: 0px; border-bottom-left-radius: 0px; }" - ".right { border-right-style: none; border-top-right-radius: 0px; border-bottom-right-radius: 0px; }", - -1); + gtk_css_provider_load_from_string (provider, + "label { border: 3px solid black; border-radius: 5px; padding: 2px; }" + ".top { border-top-style: none; border-top-right-radius: 0px; border-top-left-radius: 0px; }" + ".bottom { border-bottom-style: none; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; }" + ".left { border-left-style: none; border-top-left-radius: 0px; border-bottom-left-radius: 0px; }" + ".right { border-right-style: none; border-top-right-radius: 0px; border-bottom-right-radius: 0px; }"); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); diff --git a/tests/testpopup.c b/tests/testpopup.c index 265ba10e9b..ebf467ec16 100644 --- a/tests/testpopup.c +++ b/tests/testpopup.c @@ -59,7 +59,7 @@ main (int argc, char *argv[]) gtk_init (); provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, css, -1); + gtk_css_provider_load_from_string (provider, css); gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider),