class LinksDemo
Links¶ ↑
GtkLabel can show hyperlinks. The default action is to call gtk_show_uri() on their URI, but it is possible to override this with a custom handler.
Public Class Methods
new(main_window)
click to toggle source
# File gtk3/sample/gtk-demo/links.rb, line 12 def initialize(main_window) @window = Gtk::Window.new(:toplevel) @window.screen = main_window.screen @window.title = "Links" label = Gtk::Label.new(<<-MESSAGE) Some <a href="http://en.wikipedia.org/wiki/Text" title="plain text">text</a> may be marked up as hyperlinks, which can be clicked or activated via <a href="keynav">keynav</a> and they work fine with other markup, like when searching on <a href="http://www.google.com/"> <span color="#0266C8">G</span><span color="#F90101">o</span> <span color="#F2B50F">o</span><span color="#0266C8">g</span> <span color="#00933B">l</span><span color="#F90101">e</span> </a>. MESSAGE label.use_markup = true label.signal_connect "activate-link" do |widget, uri| if uri == "keynav" generate_dialog(widget) true else false end end @window.add(label) label.show end
Public Instance Methods
run()
click to toggle source
# File gtk3/sample/gtk-demo/links.rb, line 44 def run if !@window.visible? @window.show_all else @window.destroy end @window end