From 8c489bc46515e6903b911cf3dcf56469c7a00f67 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Thu, 13 Jan 2022 13:09:06 -0300 Subject: [PATCH] Support hiding by name using underscore (#437) --- docs/Quicktips.md | 31 +++++++++++++++++++++++++++++++ panels/fan.py | 4 ++++ panels/gcode_macros.py | 4 +++- panels/settings.py | 3 +++ panels/temperature.py | 3 +++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 docs/Quicktips.md diff --git a/docs/Quicktips.md b/docs/Quicktips.md new file mode 100644 index 00000000..b3d1fe4b --- /dev/null +++ b/docs/Quicktips.md @@ -0,0 +1,31 @@ +# Quicktips +quick tips, without much explanation + +### Hide macros, outputs or fans + +As you probably already noticed, you can show and hide the gcode macros in the interface settings, but there is more… + +Did you know, that you can also hide gcode macros by prefixing the name with an underscore? + +``` +[gcode_macro MY_AWESOME_GCODE] +gcode: + _MY_HELPER_CODE +[gcode_macro _MY_HELPER_CODE] +gcode: + M300 +``` + +MY_AWESOME_GCODE appears in your interface settings, _MY_HELPER_CODE not. + +Another example: + +Lets hide a temperature_fan: + +``` +[temperature_fan fan1] +[temperature_fan _fan2] +``` + +fan1 will show in the interface, but _fan2 will be hidden. + diff --git a/panels/fan.py b/panels/fan.py index e3df2421..d5c1ab9c 100644 --- a/panels/fan.py +++ b/panels/fan.py @@ -139,6 +139,10 @@ class FanPanel(ScreenPanel): def load_fans(self): fans = self._printer.get_fans() for fan in fans: + # Support for hiding devices by name + name = " ".join(fan.split(" ")[1:]) if not (fan == "fan") else fan + if name.startswith("_"): + continue self.add_fan(fan) def set_fan_speed(self, widget, fan): diff --git a/panels/gcode_macros.py b/panels/gcode_macros.py index 0b7ffba4..a7660e18 100644 --- a/panels/gcode_macros.py +++ b/panels/gcode_macros.py @@ -37,7 +37,9 @@ class MacroPanel(ScreenPanel): self.load_gcode_macros() def add_gcode_macro(self, macro): - + # Support for hiding macros by name + if macro.startswith("_"): + return frame = Gtk.Frame() frame.set_property("shadow-type", Gtk.ShadowType.NONE) frame.get_style_context().add_class("frame-item") diff --git a/panels/settings.py b/panels/settings.py index 26072494..2c46d36a 100644 --- a/panels/settings.py +++ b/panels/settings.py @@ -44,6 +44,9 @@ class SettingsPanel(ScreenPanel): for macro in self._printer.get_config_section_list("gcode_macro "): macro = macro[12:] + # Support for hiding macros by name + if macro.startswith("_"): + continue self.macros[macro] = { "name": macro, "section": "displayed_macros %s" % self._screen.connected_printer, diff --git a/panels/temperature.py b/panels/temperature.py index 0238bccd..cd4f70a6 100644 --- a/panels/temperature.py +++ b/panels/temperature.py @@ -235,6 +235,9 @@ class TemperaturePanel(ScreenPanel): if not (device.startswith("extruder") or device.startswith("heater_bed")): devname = " ".join(device.split(" ")[1:]) + # Support for hiding devices by name + if devname.startswith("_"): + return else: devname = device