def init(self): self.text_view.set_property('expand', True) self.text_view.connect('button-release-event', self.on_button_release) self.text_view.connect('key-press-event', self.on_key_press) self.text_buffer.create_tag('hyperlink', foreground="#0000FF", underline=Pango.Underline.SINGLE) self.text_view.connect('motion-notify-event', self.on_hover_hyperlink) self.overlay = Gtk.Overlay() self.overlay.add(self.scrolled_window) self.hyperlink_target = Gtk.Label() self.hyperlink_target.set_alignment(0., 1.) # need an EventBox for an opaque background behind the label box = Gtk.EventBox() box.add(self.hyperlink_target) box.override_background_color(Gtk.StateFlags.NORMAL, get_background_color()) box.set_hexpand(False) box.set_vexpand(False) box.set_valign(Gtk.Align.END) box.set_halign(Gtk.Align.START) self.overlay.add_overlay(box) self.overlay.set_overlay_pass_through(box, True) self.main_component = self.overlay return self.text_view
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)
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
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
def on_shownotes_message_expose_event(self, drawingarea, ctx): background = get_background_color() if background is None: background = Gdk.RGBA(1, 1, 1, 1) ctx.set_source_rgba(background.red, background.green, background.blue, 1) x1, y1, x2, y2 = ctx.clip_extents() ctx.rectangle(x1, y1, x2 - x1, y2 - y1) ctx.fill() width, height = drawingarea.get_allocated_width(), drawingarea.get_allocated_height(), text = _('Please select an episode') draw_text_box_centered(ctx, drawingarea, width, height, text, None, None) return False