css: simplify graph_labels

This commit is contained in:
alfrix 2023-08-14 13:54:21 -03:00
parent 06b2246db1
commit fb0d0bb909
3 changed files with 9 additions and 31 deletions

View File

@ -60,11 +60,9 @@ class Panel(MenuPanel):
self.labels['da'].set_showing(device, visible) self.labels['da'].set_showing(device, visible)
if visible: if visible:
count += 1 count += 1
self.devices[device]['name'].get_style_context().add_class(self.devices[device]['class']) self.devices[device]['name'].get_style_context().add_class("graph_label")
self.devices[device]['name'].get_style_context().remove_class("graph_label_hidden")
else: else:
self.devices[device]['name'].get_style_context().add_class("graph_label_hidden") self.devices[device]['name'].get_style_context().remove_class("graph_label")
self.devices[device]['name'].get_style_context().remove_class(self.devices[device]['class'])
if count > 0: if count > 0:
if self.labels['da'] not in self.left_panel: if self.labels['da'] not in self.left_panel:
self.left_panel.add(self.labels['da']) self.left_panel.add(self.labels['da'])
@ -148,11 +146,10 @@ class Panel(MenuPanel):
name = self._gtk.Button(image, self.prettify(devname), None, self.bts, Gtk.PositionType.LEFT, 1) name = self._gtk.Button(image, self.prettify(devname), None, self.bts, Gtk.PositionType.LEFT, 1)
name.connect("clicked", self.toggle_visibility, device) name.connect("clicked", self.toggle_visibility, device)
name.set_alignment(0, .5) name.set_alignment(0, .5)
name.get_style_context().add_class(class_name)
visible = self._config.get_config().getboolean(f"graph {self._screen.connected_printer}", device, fallback=True) visible = self._config.get_config().getboolean(f"graph {self._screen.connected_printer}", device, fallback=True)
if visible: if visible:
name.get_style_context().add_class(class_name) name.get_style_context().add_class("graph_label")
else:
name.get_style_context().add_class("graph_label_hidden")
self.labels['da'].set_showing(device, visible) self.labels['da'].set_showing(device, visible)
temp = self._gtk.Button(label="", lines=1) temp = self._gtk.Button(label="", lines=1)

View File

@ -173,11 +173,9 @@ class Panel(ScreenPanel):
self.labels['da'].set_showing(device, visible) self.labels['da'].set_showing(device, visible)
if visible: if visible:
count += 1 count += 1
self.devices[device]['name'].get_style_context().add_class(self.devices[device]['class']) self.devices[device]['name'].get_style_context().add_class("graph_label")
self.devices[device]['name'].get_style_context().remove_class("graph_label_hidden")
else: else:
self.devices[device]['name'].get_style_context().add_class("graph_label_hidden") self.devices[device]['name'].get_style_context().remove_class("graph_label")
self.devices[device]['name'].get_style_context().remove_class(self.devices[device]['class'])
if count > 0: if count > 0:
if self.labels['da'] not in self.left_panel: if self.labels['da'] not in self.left_panel:
self.left_panel.add(self.labels['da']) self.left_panel.add(self.labels['da'])
@ -324,11 +322,10 @@ class Panel(ScreenPanel):
name = self._gtk.Button(image, self.prettify(devname), None, self.bts, Gtk.PositionType.LEFT, 1) name = self._gtk.Button(image, self.prettify(devname), None, self.bts, Gtk.PositionType.LEFT, 1)
name.set_alignment(0, .5) name.set_alignment(0, .5)
name.get_style_context().add_class(class_name)
visible = self._config.get_config().getboolean(f"graph {self._screen.connected_printer}", device, fallback=True) visible = self._config.get_config().getboolean(f"graph {self._screen.connected_printer}", device, fallback=True)
if visible: if visible:
name.get_style_context().add_class(class_name) name.get_style_context().add_class("graph_label")
else:
name.get_style_context().add_class("graph_label_hidden")
can_target = self._printer.device_has_target(device) can_target = self._printer.device_has_target(device)
self.labels['da'].add_object(device, "temperatures", rgb, False, True) self.labels['da'].add_object(device, "temperatures", rgb, False, True)

View File

@ -566,20 +566,4 @@ popover button {
padding-bottom: 0; padding-bottom: 0;
} }
/* Hardcoded values until creation of dynamic CSS updates */ .graph_label {border-left-width: .4em; border-left-style: solid;}
.graph_label_hidden {padding-left: .9em;} /* .4em on top of normal button padding */
.graph_label_extruder {border-left-width: .4em; border-left-style: solid;}
.graph_label_extruder1 {border-left-width: .4em; border-left-style: solid;}
.graph_label_extruder2 {border-left-width: .4em; border-left-style: solid;}
.graph_label_extruder3 {border-left-width: .4em; border-left-style: solid;}
.graph_label_extruder4 {border-left-width: .4em; border-left-style: solid;}
.graph_label_heater_bed {border-left-width: .4em; border-left-style: solid;}
.graph_label_fan_1 {border-left-width: .4em; border-left-style: solid;}
.graph_label_fan_2 {border-left-width: .4em; border-left-style: solid;}
.graph_label_fan_3 {border-left-width: .4em; border-left-style: solid;}
.graph_label_fan_4 {border-left-width: .4em; border-left-style: solid;}
.graph_label_sensor_1 {border-left-width: .4em; border-left-style: solid;}
.graph_label_sensor_2 {border-left-width: .4em; border-left-style: solid;}
.graph_label_sensor_3 {border-left-width: .4em; border-left-style: solid;}
.graph_label_sensor_4 {border-left-width: .4em; border-left-style: solid;}
.graph_label_sensor_5 {border-left-width: .4em; border-left-style: solid;}