+ submenu_match = self.submenu_title_pattern.match(charLine)
+ if submenu_match:
+ submenu_title = submenu_match.group(1)
+ # remove title part from remainder:
+ charLine = charLine[submenu_match.end():]
+ else:
+ submenu_title = ''.join(
+ self.description_pattern.split(charLine)[::2])
+ parentItem = self.create_menu_item(submenu_title)
+ subMenu = Gtk.Menu()
+ while charLine:
+ char = charLine[0]
+ charLine = charLine[1:]
+ description_match = self.description_pattern.match(charLine)
+ if description_match:
+ item_title = char + ' ' + description_match.group(1)
+ # remove description part from remainder:
+ charLine = charLine[description_match.end():]
+ else:
+ item_title = char
+ subItem = self.create_menu_item(item_title)