Exemplo n.º 1
0
  def __init__(self, content=None):
    gtk.TextView.__init__(self)
    self.drawable = None
    self.model = Model()

    self.content = content

    self.overlay_color = util.get_theme_colors()["text"].darker(3).hex
    self.overlay_text = '<span weight="bold" size="xx-large" foreground="%s">%s</span>'

    self.shortener = microblog.util.getbus("URLShorten")

    self.connection = microblog.util.getbus("Connection")
    self.connection.connect_to_signal("ConnectionOnline", self.on_connection_online)
    self.connection.connect_to_signal("ConnectionOffline", self.on_connection_offline)

    self.get_buffer().connect("insert-text", self.on_add_text)
    self.get_buffer().connect("changed", self.on_text_changed)
    self.connect("expose-event", self.expose_view)
    self.connect("size-allocate", self.on_size_allocate)

    # set properties
    self.set_border_width(0)
    self.set_accepts_tab(True)
    self.set_editable(False)
    self.set_cursor_visible(True)
    self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
    self.set_left_margin(2)
    self.set_right_margin(2)
    self.set_pixels_above_lines(2)
    self.set_pixels_below_lines(2)

    self.base_color = util.get_style().base[gtk.STATE_NORMAL]
    self.error_color = gtk.gdk.color_parse("indianred")

    # set state online/offline
    if not self.connection.isConnected():
      self.set_sensitive(False)

    if util.gtkspell:
      try:
        self.spell = util.gtkspell.Spell(self, None)
      except:
        pass
Exemplo n.º 2
0
  def __init__(self, content=None):
    gtk.TextView.__init__(self)
    self.drawable = None
    self.model = Model()

    self.content = content

    self.overlay_color = util.get_theme_colors()["text"].darker(3).hex
    self.overlay_text = '<span weight="bold" size="xx-large" foreground="%s">%s</span>'

    self.shortener = microblog.util.getbus("URLShorten")

    self.connection = microblog.util.getbus("Connection")
    self.connection.connect_to_signal("ConnectionOnline", self.on_connection_online)
    self.connection.connect_to_signal("ConnectionOffline", self.on_connection_offline)

    self.get_buffer().connect("insert-text", self.on_add_text)
    self.get_buffer().connect("changed", self.on_text_changed)
    self.connect("expose-event", self.expose_view)
    self.connect("size-allocate", self.on_size_allocate)

    # set properties
    self.set_border_width(0)
    self.set_accepts_tab(True)
    self.set_editable(False)
    self.set_cursor_visible(True)
    self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
    self.set_left_margin(2)
    self.set_right_margin(2)
    self.set_pixels_above_lines(2)
    self.set_pixels_below_lines(2)

    self.base_color = util.get_style().base[gtk.STATE_NORMAL]
    self.error_color = gtk.gdk.color_parse("indianred")

    # set state online/offline
    if not self.connection.isConnected():
      self.set_sensitive(False)

    if util.gtkspell:
      try:
        self.spell = util.gtkspell.Spell(self, None)
      except:
        pass
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(), 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