class AssistantDemo

# Copyright © 2016 Ruby-GNOME2 Project Team # This program is licenced under the same licence as Ruby-GNOME2. #

Assistant

Demonstrates a sample multi-step assistant. Assistants are used to divide
an operation into several simpler sequential steps, and to guide the user
through these steps.

Public Class Methods

new(main_window) click to toggle source
# File gtk3/sample/gtk-demo/assistant.rb, line 12
def initialize(main_window)
  @assistant = Gtk::Assistant.new
  @assistant.screen = main_window.screen

  create_page1
  create_page2
  create_page3
  progress_bar = create_page4

  @assistant.signal_connect("cancel", &:destroy)

  @assistant.signal_connect("close", &:destroy)

  @assistant.signal_connect "apply" do |widget|
    GLib::Timeout.add(100) do
      fraction = progress_bar.fraction + 0.05
      if fraction < 1.0
        progress_bar.fraction = fraction
      else
        widget.destroy
        GLib::Source::REMOVE
      end
    end
  end

  @assistant.signal_connect "prepare" do |widget, _page|
    current_page = widget.current_page
    n_pages = widget.n_pages

    widget.title = "Sample assistant (#{current_page + 1} of #{n_pages}"

    widget.commit if current_page == 3
  end
end

Public Instance Methods

run() click to toggle source
# File gtk3/sample/gtk-demo/assistant.rb, line 47
def run
  if !@assistant.visible?
    @assistant.show_all
  else
    @assistant.destroy
  end
  @assistant
end