[gnome-builder] Stop using deprecated gtk_style_context_get_*color() functions
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] Stop using deprecated gtk_style_context_get_*color() functions
- Date: Fri, 1 Jan 2021 19:42:21 +0000 (UTC)
commit a012c9efd0bda9a46cc3b0a2d5ca702ef87e525d
Author: vanadiae <vanadiae35 gmail com>
Date: Fri Jan 1 00:34:28 2021 +0100
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.
src/libide/terminal/ide-terminal-page.c | 9 ++-------
src/libide/terminal/ide-terminal.c | 9 ++-------
src/plugins/glade/gbp-glade-page.c | 6 ++----
src/plugins/ls/gbp-ls-page.c | 8 ++------
src/plugins/omni-gutter/gbp-omni-gutter-renderer.c | 10 ++--------
5 files changed, 10 insertions(+), 32 deletions(-)
---
diff --git a/src/libide/terminal/ide-terminal-page.c b/src/libide/terminal/ide-terminal-page.c
index a4d3b7459..e6d0d687d 100644
--- a/src/libide/terminal/ide-terminal-page.c
+++ b/src/libide/terminal/ide-terminal-page.c
@@ -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");
diff --git a/src/libide/terminal/ide-terminal.c b/src/libide/terminal/ide-terminal.c
index 3170a55a6..53c6c18f8 100644
--- a/src/libide/terminal/ide-terminal.c
+++ b/src/libide/terminal/ide-terminal.c
@@ -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");
diff --git a/src/plugins/glade/gbp-glade-page.c b/src/plugins/glade/gbp-glade-page.c
index d60abcd72..2f5e69783 100644
--- a/src/plugins/glade/gbp-glade-page.c
+++ b/src/plugins/glade/gbp-glade-page.c
@@ -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);
diff --git a/src/plugins/ls/gbp-ls-page.c b/src/plugins/ls/gbp-ls-page.c
index a438eea6a..44af4154c 100644
--- a/src/plugins/ls/gbp-ls-page.c
+++ b/src/plugins/ls/gbp-ls-page.c
@@ -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);
diff --git a/src/plugins/omni-gutter/gbp-omni-gutter-renderer.c
b/src/plugins/omni-gutter/gbp-omni-gutter-renderer.c
index 5bb5d41a3..9466c01aa 100644
--- a/src/plugins/omni-gutter/gbp-omni-gutter-renderer.c
+++ b/src/plugins/omni-gutter/gbp-omni-gutter-renderer.c
@@ -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))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]