gtk: do not try to ellipsize if the label is None

This commit is contained in:
alfrix 2022-08-17 14:36:25 -03:00 committed by Alfredo Monclus
parent f60a878e7b
commit ea5c5afa5e

View File

@ -173,16 +173,17 @@ class KlippyGtk:
b.set_image_position(position) b.set_image_position(position)
b.set_always_show_image(True) b.set_always_show_image(True)
try: if label is not None:
# Get the label object try:
child = b.get_children()[0].get_children()[0].get_children()[1] # Get the label object
child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) child = b.get_children()[0].get_children()[0].get_children()[1]
child.set_line_wrap(True) child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
child.set_ellipsize(True) child.set_line_wrap(True)
child.set_ellipsize(Pango.EllipsizeMode.END) child.set_ellipsize(True)
child.set_lines(lines) child.set_ellipsize(Pango.EllipsizeMode.END)
except Exception as e: child.set_lines(lines)
logging.debug(f"Unable to wrap and ellipsize label: {e}") except Exception as e:
logging.debug(f"Unable to wrap and ellipsize label: {image_name} {label} {e}")
if style is not None: if style is not None:
b.get_style_context().add_class(style) b.get_style_context().add_class(style)