code: def parse(self, color):
          
          assert color is not None
  
          #parse color into rgb values
          if isinstance(color, str):
              match = self.hex_color_long.match(color)
              if match:
                  color = [int(color, 16) / 65535.0 for color in match.groups()]
              else:
                  match = self.hex_color_normal.match(color)
                  if match:
                      color = [int(color, 16) / 255.0 for color in match.groups()]
                  else:
                      match = self.hex_color_short.match(color)
                      color = [int(color + color, 16) / 255.0 for color in match.groups()]
  
          elif isinstance(color, gdk.Color):
              color = [color.red / 65535.0,
                       color.green / 65535.0,
                       color.blue / 65535.0]
  
          elif isinstance(color, (list, tuple)):
              # otherwise we assume we have color components in 0..255 range
              if color[0] > 1 or color[1] > 1 or color[2] > 1:
                  color = [c / 255.0 for c in color]
          else:
              color = [color.red, color.green, color.blue]
  
  
          return color
docs: parse string or a color tuple into color usable for cairo (all values
          in the normalized (0..1) range