class Rgw::RadioRevealer

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/rgw/radio-revealer.rb, line 27
def initialize
    super(:orientation => :vertical)

    @radioGroup = nil
    @revealers = []
    @revealerButtons = []
    @lastRevealed = nil
end

Public Instance Methods

active() click to toggle source
# File lib/rgw/radio-revealer.rb, line 99
def active
    @lastRevealed
end
active=(idx)
Alias for: set_activate
create_entry(head, child=nil) click to toggle source
# File lib/rgw/radio-revealer.rb, line 37
def create_entry head, child=nil
    button = nil
    label = nil
    if head.is_a? Gtk::Widget
        label = head
    else
        label = create_group_label head
    end

    if @radioGroup.nil?
        button = Gtk::RadioButton.new
        @radioGroup = button
    else
        button = Gtk::RadioButton.new @radioGroup
    end
    @revealerButtons << button
    button.add label

    pack_start button, :expand => false, :fill => false, :padding => 6
    button.signal_connect(:toggled) do |btn|
        @revealerButtons.each_with_index do |widget, idx|
            if widget.active?
                if idx != @lastRevealed
                    @revealers[@lastRevealed].reveal_child = false unless @lastRevealed.nil?
                    @revealers[idx].reveal_child = true
                    @lastRevealed = idx
                    signal_emit :revealed, idx
                end
                break
            end
        end
    end
    rev = Gtk::Revealer.new
    @revealers << rev
    pack_start rev, :expand => false, :fill => false, :padding => 6

    rev.add child unless child.nil?

    if @revealers.length() == 1
        rev.reveal_child = true
        @lastRevealed = 0
    end
end
create_group_label(text) click to toggle source
# File lib/rgw/radio-revealer.rb, line 104
def create_group_label text
    label = Gtk::Label.new.set_xalign(0.04)
    label.markup = '<span size="large" weight="bold">' + text + '</span>'
    label
end
set_activate(idx) click to toggle source
# File lib/rgw/radio-revealer.rb, line 91
def set_activate idx
    raise ArgumentError, "invalid type %s for index" % idx.class.to_s unless idx.is_a? Integer
    raise ArgumentError, "invalid index %i" % idx.to_i unless (0..@revealers.length() -1).cover?(idx)
    @revealerButtons[idx].active = true
end
Also aliased as: active=
set_child(idx, child) click to toggle source
# File lib/rgw/radio-revealer.rb, line 82
def set_child idx, child
    raise ArgumentError, "invalid type %s for index, expect Integer" % idx.class.to_s unless idx.is_a? Integer
    raise ArgumentError, "invalid index %i" % idx.to_i unless (0..@revealers.length() -1).cover?(idx)
    raise ArgumentError, "invalid type %s for child, expect Gtk::Widget" % child.class.to_s unless child.is_a? Gtk::Widget
    @revealers[idx].remove @revealers[idx].child unless @revealers[idx].child.nil?
    @revealers[idx].add child
end
signal_do_revealed(foo;) click to toggle source
# File lib/rgw/radio-revealer.rb, line 25
def signal_do_revealed foo; end