Skip to content

Commit c815f68

Browse files
committed
Fix setting VM label in domains widgets in some circumstances
fixes QubesOS/qubes-issues#9726
1 parent 3d5af8f commit c815f68

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

qui/tray/domains.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -502,19 +502,14 @@ def __init__(self, vm, app, icon_cache, state=None):
502502
self.decorator = qui.decorators.DomainDecorator(vm)
503503

504504
# Main horizontal box
505-
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
505+
self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
506506

507507
# Icon box with fixed width
508-
iconbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
509-
iconbox.set_size_request(16, 0)
510-
icon = self.decorator.icon()
511-
if icon:
512-
iconbox.pack_start(icon, False, True, 0)
513-
else:
514-
placeholder = Gtk.Label()
515-
iconbox.pack_start(placeholder, False, True, 0)
508+
self.iconbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
509+
self.iconbox.set_size_request(16, 0)
510+
self.set_label_icon()
516511

517-
hbox.pack_start(iconbox, False, True, 6)
512+
self.hbox.pack_start(self.iconbox, False, True, 6)
518513

519514
# Name box
520515
namebox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
@@ -523,7 +518,7 @@ def __init__(self, vm, app, icon_cache, state=None):
523518
self.spinner = Gtk.Spinner()
524519
namebox.pack_start(self.spinner, False, True, 0)
525520

526-
hbox.pack_start(namebox, True, True, 0)
521+
self.hbox.pack_start(namebox, True, True, 0)
527522

528523
# Memory and CPU box
529524
mem_cpu_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
@@ -532,10 +527,10 @@ def __init__(self, vm, app, icon_cache, state=None):
532527
self.cpu = self.decorator.cpu()
533528
mem_cpu_box.pack_start(self.cpu, False, True, 0)
534529

535-
hbox.pack_start(mem_cpu_box, False, True, 0)
530+
self.hbox.pack_start(mem_cpu_box, False, True, 0)
536531

537532
# Add hbox to the menu item
538-
self.add(hbox)
533+
self.add(self.hbox)
539534

540535
if self.vm is None: # if header
541536
self.set_reserve_indicator(True) # align with submenu triangles
@@ -618,6 +613,16 @@ def update_stats(self, memory_kb, cpu_usage):
618613
self.memory.update_state(int(memory_kb))
619614
self.cpu.update_state(int(cpu_usage))
620615

616+
def set_label_icon(self):
617+
for child in self.iconbox.get_children():
618+
self.iconbox.remove(child)
619+
icon = self.decorator.icon()
620+
if icon:
621+
self.iconbox.pack_start(icon, False, True, 0)
622+
icon.show()
623+
else:
624+
placeholder = Gtk.Label()
625+
self.iconbox.pack_start(placeholder, False, True, 0)
621626

622627
class DomainTray(Gtk.Application):
623628
"""A tray icon application listing all but halted domains. ”"""

0 commit comments

Comments
 (0)