Exemplo n.º 1
0
    def define_colors(self):
        if not self.color_set:
            self.color_set = True
            # investigate_widget_colors([
            #     ([(Gtk.Window, 'background', '')], self.status.get_toplevel()),
            #     ([(Gtk.Window, 'background', ''), (Gtk.Label, '', '')], self.status),
            #     ([(Gtk.Window, 'background', ''), (Gtk.TextView, 'view', '')], self.text_view),
            #     ([(Gtk.Window, 'background', ''), (Gtk.TextView, 'view', 'text')], self.text_view),
            # ])
            dummy_tv = Gtk.TextView()
            self.background_color = get_background_color(
                Gtk.StateFlags.NORMAL, widget=dummy_tv) or Gdk.RGBA()
            self.foreground_color = get_foreground_color(
                Gtk.StateFlags.NORMAL, widget=dummy_tv) or Gdk.RGBA(0, 0, 0)
            self.link_color = get_foreground_color(
                state=Gtk.StateFlags.LINK, widget=dummy_tv) or Gdk.RGBA(
                    0, 0, 0)
            self.visited_color = get_foreground_color(
                state=Gtk.StateFlags.VISITED,
                widget=dummy_tv) or self.link_color
            del dummy_tv

            self.status_bg.override_background_color(Gtk.StateFlags.NORMAL,
                                                     self.background_color)
            if hasattr(self, "text_buffer"):
                self.text_buffer.create_tag(
                    'hyperlink',
                    foreground=self.link_color.to_string(),
                    underline=Pango.Underline.SINGLE)
Exemplo n.º 2
0
 def get_stylesheet(self):
     if self.stylesheet is None:
         foreground = get_foreground_color()
         background = get_background_color(Gtk.StateFlags.ACTIVE)
         if background is not None:
             style = "html { background: %s; color: %s;}" % \
                         (background.to_string(), foreground.to_string())
             self.stylesheet = WebKit2.UserStyleSheet(style, 0, 1, None, None)
     return self.stylesheet
Exemplo n.º 3
0
 def get_stylesheet(self):
     if self.stylesheet is None:
         foreground = get_foreground_color()
         background = get_background_color(Gtk.StateFlags.ACTIVE)
         if background is not None:
             style = "html { background: %s; color: %s;}" % \
                         (background.to_string(), foreground.to_string())
             self.stylesheet = WebKit2.UserStyleSheet(
                 style, 0, 1, None, None)
     return self.stylesheet