Skip to content

Commit

Permalink
widget rendering: Simplify underline creation
Browse files Browse the repository at this point in the history
See-Also: #1 (review)
  • Loading branch information
chrysn committed Jan 19, 2019
1 parent 5b016d6 commit b3fe73e
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions screenlayout/widget.py
Expand Up @@ -25,7 +25,7 @@
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('PangoCairo', '1.0')
from gi.repository import GObject, Gtk, Pango, PangoCairo, Gdk
from gi.repository import GObject, Gtk, Pango, PangoCairo, Gdk, GLib

from .snap import Snap
from .xrandr import XRandR, Feature
Expand Down Expand Up @@ -273,21 +273,13 @@ def _draw(self, xrandr, context): # pylint: disable=too-many-locals
newdescr.set_size(textheight * Pango.SCALE)

# create text
output_name_markup = GLib.markup_escape_text(output_name)
layout = PangoCairo.create_layout(context)
layout.set_font_description(newdescr)
if output.primary:
underline_attrs = Pango.parse_markup("<u>test</u>", -1, "0")[1]
# attrs = Pango.AttrList()
# attr = Pango.Attribute()
# attr_class = Pango.AttrClass()
# attr_class.type = Pango.AttrType.UNDERLINE
# attr.init(attr_class)
# attrs.insert(attr)
# attrs.insert(Pango.Underline.SINGLE)
# layout.set_attributes(attrs)
layout.set_attributes(underline_attrs)

layout.set_text(output_name, -1)
output_name_markup = "<u>%s</u>" % output_name_markup

layout.set_markup(output_name_markup, -1)

# position text
layoutsize = layout.get_pixel_size()
Expand Down

0 comments on commit b3fe73e

Please sign in to comment.