From d3803affa0b1f98922859f33d4a5a4d1510f0eca Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 10 Jul 2023 17:30:50 +0530 Subject: [PATCH] Make the dict a map of panel enum items since we cant guarantee that translated names are unique --- src/calibre/gui2/actions/layout_actions.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/calibre/gui2/actions/layout_actions.py b/src/calibre/gui2/actions/layout_actions.py index 3bf58a2551..075a4e8cee 100644 --- a/src/calibre/gui2/actions/layout_actions.py +++ b/src/calibre/gui2/actions/layout_actions.py @@ -74,17 +74,12 @@ class LayoutActions(InterfaceAction): for name in self.gui.button_order: self.set_visible(Panel(name), show=True) - def button_names(self): + def panel_titles(self): ''' - Return a dictionary of translated panel names to its Panel enum. This - simplifies building dialogs, for example combo boxes of all the panel - names or check boxes for each panel. You can also use the dict - to find the translated names of particular panels, easier after - inverting it with dict(map(reversed, instance.button_names().items())) + Return a dictionary of Panel Enum items to translated human readable title. + Simplifies building dialogs, for example combo boxes of all the panel + names or check boxes for each panel. - :return: {panel_name: Panel_enum_value, ...} + :return: {Panel_enum_value: human readable title, ...} ''' - names = {} - for p in Panel: - names[self._button_from_enum(p).label] = p - return names \ No newline at end of file + return {p: self._button_from_enum(p).label for p in Panel}