Sha256: 5a96c4cbe8331b5ee27f718fc122d3068bd81166a0a724b3b1217be5f11547a4

Contents?: true

Size: 1.99 KB

Versions: 47

Compression:

Stored size: 1.99 KB

Contents

# Copyright (c) 2013 Ruby-GNOME2 Project Team
# This program is licenced under the same licence as Ruby-GNOME2.
#
=begin
= 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.
=end
require 'common'

module Demo
  class Links < BasicWindow
    def initialize
      super('Links')

      title = 'Links'
      border_width = 12
      signal_connect(:destroy) {self.destroy}

      label = Gtk::Label.new "Some <a href=\"http://en.wikipedia.org/wiki/Text\"" +
                             "title=\"plain text\">text</a> may be marked up\n" +
                             "as hyperlinks, which can be clicked\n" +
                             "or activated via <a href=\"keynav\">keynav</a>\n" +
                             "and they work fine with other markup, like when\n" +
                             "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>."
      label.use_markup = true
      label.signal_connect(:activate_link) {|widget, uri| activate_link uri}
      add label
      label.show
    end

    def activate_link uri
      if uri == 'keynav'
        dialog = Gtk::MessageDialog.new :parent => self,
                   :flags => :destroy_with_parent,
                   :type => :info,
                   :buttons_type => :ok

        dialog.markup = "The term <i>keynav</i> is a shorthand for " +
                        "keyboard navigation and refers to the process of using " +
                        "a program (exclusively) via keyboard input."
        dialog.present
        dialog.signal_connect(:response) {dialog.destroy}
        return true
      end
      false
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
gtk3-3.0.7-x86-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.7-x64-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.7 sample/gtk-demo/links.rb
gtk3-3.0.6-x86-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.6-x64-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.6 sample/gtk-demo/links.rb
gtk3-3.0.5-x64-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.5-x86-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.5 sample/gtk-demo/links.rb
gtk3-3.0.4-x86-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.4-x64-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.4 sample/gtk-demo/links.rb
gtk3-3.0.3-x64-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.3-x86-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.3 sample/gtk-demo/links.rb
gtk3-3.0.2-x86-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.2-x64-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.2 sample/gtk-demo/links.rb
gtk3-3.0.1-x86-mingw32 sample/gtk-demo/links.rb
gtk3-3.0.1-x64-mingw32 sample/gtk-demo/links.rb