base_panel: create get_icon for show_heaters

This commit is contained in:
alfrix 2022-10-22 11:47:45 -03:00
parent 32fab0482f
commit da9051a9b2

View File

@ -130,31 +130,11 @@ class BasePanel(ScreenPanel):
img_size = self._gtk.img_scale * .5
for device in self._screen.printer.get_temp_store_devices():
if device.startswith("extruder"):
if self._screen.printer.extrudercount > 1:
if device == "extruder":
icon = self._gtk.Image("extruder-0", img_size, img_size)
else:
icon = self._gtk.Image(f"extruder-{device[8:]}", img_size, img_size)
else:
icon = self._gtk.Image("extruder", img_size, img_size)
elif device.startswith("heater_bed"):
icon = self._gtk.Image("bed", img_size, img_size)
# Extra items
elif self.titlebar_name_type is not None:
# The item has a name, do not use an icon
icon = None
elif device.startswith("temperature_fan"):
icon = self._gtk.Image("fan", img_size, img_size)
elif device.startswith("heater_generic"):
icon = self._gtk.Image("heater", img_size, img_size)
else:
icon = self._gtk.Image("heat-up", img_size, img_size)
self.labels[device] = Gtk.Label(label="100º")
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
self.labels[f'{device}_box'] = Gtk.Box()
icon = self.get_icon(device, img_size)
if icon is not None:
self.labels[f'{device}_box'].pack_start(icon, False, False, 3)
self.labels[f'{device}_box'].pack_start(self.labels[device], False, False, 0)
@ -204,6 +184,26 @@ class BasePanel(ScreenPanel):
n += 1
self.control['temp_box'].show_all()
def get_icon(self, device, img_size):
if device.startswith("extruder"):
if self._screen.printer.extrudercount > 1:
if device == "extruder":
device = "extruder0"
return self._gtk.Image(f"extruder-{device[8:]}", img_size, img_size)
return self._gtk.Image("extruder", img_size, img_size)
elif device.startswith("heater_bed"):
return self._gtk.Image("bed", img_size, img_size)
# Extra items
elif self.titlebar_name_type is not None:
# The item has a name, do not use an icon
return None
elif device.startswith("temperature_fan"):
return self._gtk.Image("fan", img_size, img_size)
elif device.startswith("heater_generic"):
return self._gtk.Image("heater", img_size, img_size)
else:
return self._gtk.Image("heat-up", img_size, img_size)
def activate(self):
if self.time_update is None:
self.time_update = GLib.timeout_add_seconds(1, self.update_time)