[planner: 15/32] charts: Restore default white background via GtkStyleContext
- From: Mart Raudsepp <mraudsepp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner: 15/32] charts: Restore default white background via GtkStyleContext
- Date: Sun, 20 Jun 2021 18:13:51 +0000 (UTC)
commit 4374f46714944cda77c1239403ab3f73cf29ba8c
Author: Mart Raudsepp <leio gentoo org>
Date: Sun May 30 23:30:40 2021 +0300
charts: Restore default white background via GtkStyleContext
src/planner-gantt-chart.c | 22 +++++++++++++++++-----
src/planner-usage-chart.c | 24 ++++++++++++++++++------
2 files changed, 35 insertions(+), 11 deletions(-)
---
diff --git a/src/planner-gantt-chart.c b/src/planner-gantt-chart.c
index f8dd7418..36a12f77 100644
--- a/src/planner-gantt-chart.c
+++ b/src/planner-gantt-chart.c
@@ -574,8 +574,10 @@ gantt_chart_realize (GtkWidget *widget)
{
PlannerGanttChart *chart;
PlannerGanttChartPriv *priv;
- GtkStyle *style;
+ GtkCssProvider *css_provider;
+ GtkStyleContext *style_context;
GtkWidget *canvas;
+ GError *error = NULL;
chart = PLANNER_GANTT_CHART (widget);
priv = chart->priv;
@@ -587,10 +589,20 @@ gantt_chart_realize (GtkWidget *widget)
}
/* Set the background to white. */
- style = gtk_style_copy (gtk_widget_get_style (canvas));
- gdk_color_parse ("white", &style->bg[GTK_STATE_NORMAL]);
- gtk_widget_set_style (canvas, style);
- g_object_unref (style);
+ css_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (css_provider,
+ "@define-color theme_bg_color white;",
+ -1, &error);
+ style_context = gtk_widget_get_style_context (canvas);
+ if (error == NULL) {
+ gtk_style_context_add_provider (style_context,
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ } else {
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_clear_error (&error);
+ }
+ g_object_unref (css_provider);
gantt_chart_set_zoom (chart, priv->zoom);
}
diff --git a/src/planner-usage-chart.c b/src/planner-usage-chart.c
index dacfc6b6..32e3c06d 100644
--- a/src/planner-usage-chart.c
+++ b/src/planner-usage-chart.c
@@ -683,8 +683,10 @@ usage_chart_realize (GtkWidget *widget)
{
PlannerUsageChart *chart;
PlannerUsageChartPriv *priv;
- GtkWidget *canvas;
- GtkStyle *style;
+ GtkWidget *canvas;
+ GtkStyleContext *style_context;
+ GtkCssProvider *css_provider;
+ GError *error = NULL;
chart = PLANNER_USAGE_CHART (widget);
priv = chart->priv;
@@ -696,10 +698,20 @@ usage_chart_realize (GtkWidget *widget)
}
/* Set the background to white. */
- style = gtk_style_copy (gtk_widget_get_style (canvas));
- gdk_color_parse ("white", &style->bg[GTK_STATE_NORMAL]);
- gtk_widget_set_style (canvas, style);
- g_object_unref (style);
+ css_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (css_provider,
+ "@define-color theme_bg_color white;",
+ -1, &error);
+ style_context = gtk_widget_get_style_context (canvas);
+ if (error == NULL) {
+ gtk_style_context_add_provider (style_context,
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ } else {
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_clear_error (&error);
+ }
+ g_object_unref (css_provider);
usage_chart_set_zoom (chart, priv->zoom);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]