[gnome-builder] ls: propagate primary color from treeview



commit 564a97427f0d3091e0fe441e1cebe8f5c469ef5b
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 26 00:20:44 2019 -0700

    ls: propagate primary color from treeview

 src/plugins/ls/gbp-ls-page.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/src/plugins/ls/gbp-ls-page.c b/src/plugins/ls/gbp-ls-page.c
index 2b86bc75c..b25cf0be8 100644
--- a/src/plugins/ls/gbp-ls-page.c
+++ b/src/plugins/ls/gbp-ls-page.c
@@ -130,6 +130,31 @@ size_cell_data_func (GtkCellLayout   *cell_layout,
   g_object_set (cell, "text", format, NULL);
 }
 
+static void
+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));
+
+  if (GTK_WIDGET_CLASS (gbp_ls_page_parent_class)->style_updated)
+    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;
+
+  ide_page_set_primary_color_bg (IDE_PAGE (self), &bg);
+  ide_page_set_primary_color_fg (IDE_PAGE (self), &fg);
+}
+
 static void
 gbp_ls_page_finalize (GObject *object)
 {
@@ -197,6 +222,8 @@ gbp_ls_page_class_init (GbpLsPageClass *klass)
   object_class->get_property = gbp_ls_page_get_property;
   object_class->set_property = gbp_ls_page_set_property;
 
+  widget_class->style_updated = gbp_ls_page_style_updated;
+
   properties [PROP_DIRECTORY] =
     g_param_spec_object ("directory",
                          "Directory",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]