Exemplo n.º 1
0
def icon(name, size=16, use_theme=True):
  if use_theme:
    theme_path = resources.get_theme_path(resources.THEME_NAME)
    if theme_path:
      fname = os.path.join(theme_path, name)
      for ext in [".svg", ".png"]:
        if os.path.exists(fname + ext):
          return fname + ext

  theme = Gtk.IconTheme.get_default()
  finfo = theme.lookup_icon(name, size, 0)
  return finfo.get_filename() if finfo else None
Exemplo n.º 2
0
def icon(name, size=16, use_theme=True):
  if use_theme:
    theme_path = resources.get_theme_path(resources.THEME_NAME)
    if theme_path:
      fname = os.path.join(theme_path, name)
      for ext in [".svg", ".png"]:
        if os.path.exists(fname + ext):
          return fname + ext

  theme = gtk.icon_theme_get_default()
  finfo = theme.lookup_icon(name, size, 0)
  return finfo.get_filename() if finfo else None
Exemplo n.º 3
0
  def render(self, theme, template, **kwargs):
    default_font = self.gc.get_string("/desktop/gnome/interface/document_font_name")
    if default_font:
      font_name, font_size = default_font.rsplit(None, 1)
      self.web_settings.set_property("sans-serif-font-family", font_name)
      self.web_settings.set_property("default-font-size", float(font_size))

    if not resources.theme_exists(theme):
      theme = "default"

    theme_path = resources.get_theme_path(theme)
    template_path = resources.get_template_path(template, theme)
    lookup_paths = list(resources.get_template_dirs()) + [theme_path]

    template = open(template_path).read()
    template = Template(template, lookup=TemplateLookup(directories=lookup_paths))
    content = template.render(theme=util.get_theme_colors(), util=util, resources=resources, _=_, **kwargs)

    # Avoid navigation redraw crashes
    if isinstance(self, Navigation) and not self.get_property("visible"):
      return content

    self.load_html_string(content, "file://%s/" % os.path.dirname(template_path))
    return content
Exemplo n.º 4
0
  def render(self, theme, template, **kwargs):
    default_font = self.gc.get_string("/desktop/gnome/interface/document_font_name")
    if default_font:
      font_name, font_size = default_font.rsplit(None, 1)
      self.web_settings.set_property("sans-serif-font-family", font_name)
      self.web_settings.set_property("default-font-size", float(font_size))

    if not resources.theme_exists(theme):
      theme = "default"

    theme_path = resources.get_theme_path(theme)
    template_path = resources.get_template_path(template, theme)
    lookup_paths = list(resources.get_template_dirs()) + [theme_path]

    template = open(template_path).read()
    template = Template(template, lookup=TemplateLookup(directories=lookup_paths))
    content = template.render(theme=util.get_theme_colors(), util=util, resources=resources, _=_, **kwargs)

    # Avoid navigation redraw crashes
    if isinstance(self, Navigation) and not self.get_property("visible"):
      return content

    self.load_html_string(content, "file://%s/" % os.path.dirname(template_path))
    return content