Commit a012c9ef authored by Vanadiae's avatar Vanadiae Committed by Christian Hergert
Browse files

Stop using deprecated gtk_style_context_get_*color() functions

Currently in various place, gtk_style_context_get_color() and
gtk_style_context_get_background_color() are used to get and replicate
the color a color to an other place.

The later is deprecated in GTK3 and removed in GTK4. So this commit
uses other means to get the background color. Since the get_color()
function is quite inexpressive in the sense that you don't really know
which color you'll get (like the get_background_color()), this commit
also replaces those uses by more saner ones.
parent dc350ba1
Pipeline #242995 passed with stages
in 37 minutes and 25 seconds
......@@ -297,19 +297,14 @@ static void
style_context_changed (GtkStyleContext *style_context,
IdeTerminalPage *self)
{
GtkStateFlags state;
GdkRGBA fg;
GdkRGBA bg;
g_assert (GTK_IS_STYLE_CONTEXT (style_context));
g_assert (IDE_IS_TERMINAL_PAGE (self));
state = gtk_style_context_get_state (style_context);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_context_get_color (style_context, state, &fg);
gtk_style_context_get_background_color (style_context, state, &bg);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_style_context_lookup_color (style_context, "theme_text_color", &fg);
gtk_style_context_lookup_color (style_context, "text_view_bg", &bg);
if (bg.alpha == 0.0)
gdk_rgba_parse (&bg, "#f6f7f8");
......
......@@ -95,19 +95,14 @@ static void
style_context_changed (IdeTerminal *self,
GtkStyleContext *style_context)
{
GtkStateFlags state;
GdkRGBA fg;
GdkRGBA bg;
g_assert (GTK_IS_STYLE_CONTEXT (style_context));
g_assert (IDE_IS_TERMINAL (self));
state = gtk_style_context_get_state (style_context);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_context_get_color (style_context, state, &fg);
gtk_style_context_get_background_color (style_context, state, &bg);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_style_context_lookup_color (style_context, "theme_text_color", &fg);
gtk_style_context_lookup_color (style_context, "text_view_bg", &bg);
if (bg.alpha == 0.0)
gdk_rgba_parse (&bg, "#f6f7f8");
......
......@@ -277,10 +277,8 @@ viewport_style_changed_cb (GbpGladePage *self,
g_assert (GBP_IS_GLADE_PAGE (self));
g_assert (GTK_IS_STYLE_CONTEXT (style_context));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_context_get_color (style_context, GTK_STATE_FLAG_NORMAL, &fg);
gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_NORMAL, &bg);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_style_context_lookup_color (style_context, "theme_fg_color", &fg);
gtk_style_context_lookup_color (style_context, "theme_base_color", &bg);
ide_page_set_primary_color_bg (IDE_PAGE (self), &bg);
ide_page_set_primary_color_fg (IDE_PAGE (self), &fg);
......
......@@ -140,7 +140,6 @@ gbp_ls_page_style_updated (GtkWidget *widget)
{
GbpLsPage *self = (GbpLsPage *)widget;
GtkStyleContext *style_context;
GtkStateFlags state;
GdkRGBA bg, fg;
g_assert (GBP_IS_LS_PAGE (self));
......@@ -149,12 +148,9 @@ gbp_ls_page_style_updated (GtkWidget *widget)
GTK_WIDGET_CLASS (gbp_ls_page_parent_class)->style_updated (widget);
style_context = gtk_widget_get_style_context (GTK_WIDGET (self->tree_view));
state = gtk_style_context_get_state (style_context);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_context_get_color (style_context, state, &fg);
gtk_style_context_get_background_color (style_context, state, &bg);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_style_context_lookup_color (style_context, "theme_fg_color", &fg);
gtk_style_context_lookup_color (style_context, "theme_base_color", &bg);
ide_page_set_primary_color_bg (IDE_PAGE (self), &bg);
ide_page_set_primary_color_fg (IDE_PAGE (self), &fg);
......
......@@ -385,9 +385,7 @@ static void
reload_style_colors (GbpOmniGutterRenderer *self,
GtkSourceStyleScheme *scheme)
{
GtkStyleContext *context;
GtkTextView *view;
GtkStateFlags state;
GdkRGBA fg;
GdkRGBA bg;
......@@ -398,12 +396,8 @@ reload_style_colors (GbpOmniGutterRenderer *self,
if (view == NULL)
return;
context = gtk_widget_get_style_context (GTK_WIDGET (view));
state = gtk_style_context_get_state (context);
gtk_style_context_get_color (context, state, &fg);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_context_get_background_color (context, state, &bg);
G_GNUC_END_IGNORE_DEPRECATIONS;
get_style_rgba (scheme, "line-numbers", FOREGROUND, &fg);
get_style_rgba (scheme, "line-numbers", BACKGROUND, &bg);
/* Extract common values from style schemes. */
if (!get_style_rgba (scheme, "line-numbers", FOREGROUND, &self->text.fg))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment