Sha256: d2a386e1acbbf654874aa2f1bdb2486840b3b1374e8c52935c3f98c1d7aceb0e

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

# Copyright (c) 2015 Ruby-GNOME2 Project Team
# This program is licenced under the same licence as Ruby-GNOME2.
#
=begin
= Text View/Markup

Gtk::TextBuffer lets you define your own tags that can influence
text formatting in a variety of ways. In this example, we show
that Gtk::TextBuffer can load Pango markup and automatically generate
suitable tags.

=end
module MarkupDemo

  def self.run_demo(main_window)
    window = Gtk::Window.new(:toplevel)
    window.screen = main_window.screen
    window.set_default_size(450, 450)

    window.set_title("Markup")

    view = Gtk::TextView.new
    view.set_wrap_mode(:word)
    view.set_left_margin(10)
    view.set_right_margin(10)

    sw = Gtk::ScrolledWindow.new(nil, nil)
    sw.set_policy(:never, :automatic)

    window.add(sw)
    sw.add(view)

    markup = Gio::Resources.lookup_data("/markup/markup.txt", 0)
    
    buffer = view.buffer
    buffer.insert_markup(buffer.start_iter, markup, -1)

    sw.show_all

    if !window.visible?
      window.show_all
    else
      window.destroy
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gtk3-3.0.8-x86-mingw32 sample/gtk-demo/markup.rb
gtk3-3.0.8-x64-mingw32 sample/gtk-demo/markup.rb
gtk3-3.0.8 sample/gtk-demo/markup.rb