Commit 52529905 authored by Kai Willadsen's avatar Kai Willadsen

Fix style context state access for GTK+ 3.20 rules

parent 5d66a791
...@@ -207,7 +207,11 @@ def setup_resources(): ...@@ -207,7 +207,11 @@ def setup_resources():
# do this on the widget itself. # do this on the widget itself.
textview = Gtk.TextView() textview = Gtk.TextView()
textview_context = textview.get_style_context() textview_context = textview.get_style_context()
bg_colour = textview_context.get_background_color(Gtk.StateFlags.NORMAL) textview_context.save()
textview_context.set_state(Gtk.StateFlags.NORMAL)
bg_colour = textview_context.get_background_color(
textview_context.get_state())
textview_context.restore()
linkmap_css = "LinkMap { background-color: %s; }" % bg_colour.to_string() linkmap_css = "LinkMap { background-color: %s; }" % bg_colour.to_string()
linkmap_provider = Gtk.CssProvider() linkmap_provider = Gtk.CssProvider()
linkmap_provider.load_from_data(linkmap_css) linkmap_provider.load_from_data(linkmap_css)
......
...@@ -49,8 +49,13 @@ class NotebookLabel(Gtk.HBox): ...@@ -49,8 +49,13 @@ class NotebookLabel(Gtk.HBox):
label.set_alignment(0.0, 0.5) label.set_alignment(0.0, 0.5)
label.set_padding(0, 0) label.set_padding(0, 0)
style_context = self.get_style_context()
style_context.save()
style_context.set_state(Gtk.StateFlags.NORMAL)
font_desc = style_context.get_font(style_context.get_state())
style_context.restore()
context = self.get_pango_context() context = self.get_pango_context()
font_desc = self.get_style_context().get_font(Gtk.StateFlags.NORMAL)
metrics = context.get_metrics(font_desc, context.get_language()) metrics = context.get_metrics(font_desc, context.get_language())
char_width = metrics.get_approximate_char_width() / Pango.SCALE char_width = metrics.get_approximate_char_width() / Pango.SCALE
valid, w, h = Gtk.icon_size_lookup_for_settings( valid, w, h = Gtk.icon_size_lookup_for_settings(
......
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