[gtk/style-context-redux: 10/10] textutil: Stop using GtkStyleContext
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/style-context-redux: 10/10] textutil: Stop using GtkStyleContext
- Date: Mon, 27 Jan 2020 18:36:36 +0000 (UTC)
commit d0aa79b5a1a8970db9d55244c46806f96b7e8b0f
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 27 09:35:09 2020 -0500
textutil: Stop using GtkStyleContext
We can just use the css style directly.
gtk/gtktextutil.c | 46 +++++++++++++++++++++++++++++++---------------
1 file changed, 31 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index fa10328d46..e12ddac84e 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -30,6 +30,11 @@
#include "gtktextbuffer.h"
#include "gtktextlayoutprivate.h"
#include "gtkintl.h"
+#include "gtkwidgetprivate.h"
+#include "gtkcssnodeprivate.h"
+#include "gtkcssstyleprivate.h"
+#include "gtkstylepropertyprivate.h"
+#include "gtkcsscolorvalueprivate.h"
#define DRAG_ICON_MAX_WIDTH 250
#define DRAG_ICON_MAX_HEIGHT 250
@@ -98,13 +103,13 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
gchar *text,
gssize len)
{
- GtkStyleContext *style_context;
+ GtkCssStyle *style;
GtkSnapshot *snapshot;
PangoContext *context;
PangoLayout *layout;
GdkPaintable *paintable;
gint layout_width;
- GdkRGBA color;
+ const GdkRGBA *color;
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (text != NULL, NULL);
@@ -123,10 +128,10 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
snapshot = gtk_snapshot_new ();
- style_context = gtk_widget_get_style_context (widget);
- gtk_style_context_get_color (style_context,
- &color);
- gtk_snapshot_append_layout (snapshot, layout, &color);
+ style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
+ color = gtk_css_color_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));
+
+ gtk_snapshot_append_layout (snapshot, layout, color);
paintable = gtk_snapshot_free_to_paintable (snapshot, NULL);
g_object_unref (layout);
@@ -134,28 +139,39 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
return paintable;
}
+static GtkCssValue *
+query_func (guint id, gpointer values)
+{
+ return gtk_css_style_get_value (values, id);
+}
+
static void
-set_attributes_from_style (GtkStyleContext *context,
+set_attributes_from_style (GtkWidget *widget,
GtkTextAttributes *values)
{
+ GtkCssStyle *style;
const GdkRGBA black = { 0, };
- GdkRGBA *bg;
+ const GdkRGBA *color;
+ GValue value = G_VALUE_INIT;
if (!values->appearance.bg_rgba)
values->appearance.bg_rgba = gdk_rgba_copy (&black);
if (!values->appearance.fg_rgba)
values->appearance.fg_rgba = gdk_rgba_copy (&black);
-
- gtk_style_context_get (context, "background-color", &bg, NULL);
- *values->appearance.bg_rgba = *bg;
- gdk_rgba_free (bg);
- gtk_style_context_get_color (context, values->appearance.fg_rgba);
+ style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
+ color = gtk_css_color_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
+ *values->appearance.bg_rgba = *color;
+ color = gtk_css_color_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
+ *values->appearance.fg_rgba = *color;
if (values->font)
pango_font_description_free (values->font);
- gtk_style_context_get (context, "font", &values->font, NULL);
+ _gtk_style_property_query (_gtk_style_property_lookup ("font"), &value, query_func, style);
+
+ values->font = g_value_get_boxed (&value);
+ g_value_unset (&value);
}
static gint
@@ -216,7 +232,7 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
gtk_widget_get_allocation (widget, &allocation);
layout_width = allocation.width;
- set_attributes_from_style (gtk_widget_get_style_context (widget), style);
+ set_attributes_from_style (widget, style);
if (GTK_IS_TEXT_VIEW (widget))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]