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

This commit is contained in:
alfrix authored and Alfredo Monclus committed 2022-09-02 19:58:35 -03:00
1 parent f60a878e7b
commit ea5c5afa5e
1 file changed
+11 -10
+11 -10
View File
@@ -173,16 +173,17 @@ class KlippyGtk:
b.set_image_position(position)
b.set_always_show_image(True)
try:
# Get the label object
child = b.get_children()[0].get_children()[0].get_children()[1]
child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
child.set_line_wrap(True)
child.set_ellipsize(True)
child.set_ellipsize(Pango.EllipsizeMode.END)
child.set_lines(lines)
except Exception as e:
logging.debug(f"Unable to wrap and ellipsize label: {e}")
if label is not None:
try:
# Get the label object
child = b.get_children()[0].get_children()[0].get_children()[1]
child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
child.set_line_wrap(True)
child.set_ellipsize(True)
child.set_ellipsize(Pango.EllipsizeMode.END)
child.set_lines(lines)
except Exception as e:
logging.debug(f"Unable to wrap and ellipsize label: {image_name} {label} {e}")
if style is not None:
b.get_style_context().add_class(style)