class Rabbit::Front
Constants
- AVAILABLE_INTERFACES
Attributes
image_type[R]
last_modified[R]
public_level[R]
Public Class Methods
new(canvas, public_level=nil)
click to toggle source
Calls superclass method
# File lib/rabbit/front.rb, line 78 def initialize(canvas, public_level=nil) super() @canvas = canvas @image_type = "png" @public_level = public_level || PublicLevel::STRICT @previous_width = @canvas.width @previous_height = @canvas.height setup_public_interface clean end
Public Instance Methods
accept_move?()
click to toggle source
# File lib/rabbit/front.rb, line 154 def accept_move? not (@public_level & Front::PublicLevel::MOVE).zero? end
append_comment(comment)
click to toggle source
# File lib/rabbit/front.rb, line 158 def append_comment(comment) GLib::Idle.add do @canvas.append_comment(comment) false end true end
available_interfaces()
click to toggle source
# File lib/rabbit/front.rb, line 144 def available_interfaces AVAILABLE_INTERFACES.collect do |name, level, need_clear_cache| [name, level, @canvas.method(name).arity] end end
comments()
click to toggle source
# File lib/rabbit/front.rb, line 166 def comments @canvas.comments end
current_slide_image()
click to toggle source
# File lib/rabbit/front.rb, line 89 def current_slide_image update_images_if_need @images[@canvas.current_index] end
current_slide_number()
click to toggle source
# File lib/rabbit/front.rb, line 116 def current_slide_number @canvas.current_index end
current_slide_rd()
click to toggle source
# File lib/rabbit/front.rb, line 99 def current_slide_rd slide = @canvas.current_slide slide ? slide.to_rd : "" end
current_slide_text()
click to toggle source
# File lib/rabbit/front.rb, line 94 def current_slide_text slide = @canvas.current_slide slide ? slide.text : "" end
first_slide?()
click to toggle source
# File lib/rabbit/front.rb, line 120 def first_slide? @canvas.first_slide? end
have_next?()
click to toggle source
# File lib/rabbit/front.rb, line 132 def have_next? @canvas.have_next? end
have_next_slide?()
click to toggle source
# File lib/rabbit/front.rb, line 124 def have_next_slide? @canvas.have_next_slide? end
have_previous?()
click to toggle source
# File lib/rabbit/front.rb, line 136 def have_previous? @canvas.have_previous? end
have_previous_slide?()
click to toggle source
# File lib/rabbit/front.rb, line 128 def have_previous_slide? @canvas.have_previous_slide? end
last_slide?()
click to toggle source
# File lib/rabbit/front.rb, line 140 def last_slide? @canvas.last_slide? end
slide_title()
click to toggle source
# File lib/rabbit/front.rb, line 108 def slide_title @canvas.slide_title end
title()
click to toggle source
# File lib/rabbit/front.rb, line 104 def title @canvas.title end
total_slide_number()
click to toggle source
# File lib/rabbit/front.rb, line 112 def total_slide_number @canvas.slide_size end
version()
click to toggle source
# File lib/rabbit/front.rb, line 150 def version VERSION end
Private Instance Methods
_check_dirty()
click to toggle source
# File lib/rabbit/front.rb, line 177 def _check_dirty if dirty? clean if offscreen_canvas.need_reload_source? offscreen_canvas.reload_source synchronize end end end
check_dirty()
click to toggle source
# File lib/rabbit/front.rb, line 171 def check_dirty mon_synchronize do _check_dirty end end
clean()
click to toggle source
# File lib/rabbit/front.rb, line 256 def clean @offscreen_canvas = nil @dirty = false @images = [] @last_modified = @canvas.last_modified end
dirty!()
click to toggle source
# File lib/rabbit/front.rb, line 263 def dirty! @dirty = true end
dirty?()
click to toggle source
# File lib/rabbit/front.rb, line 204 def dirty? @dirty or @last_modified < @canvas.last_modified or offscreen_canvas.need_reload_source? end
offscreen_canvas()
click to toggle source
# File lib/rabbit/front.rb, line 267 def offscreen_canvas @offscreen_canvas ||= @canvas.offscreen_canvas end
setup_public_interface()
click to toggle source
# File lib/rabbit/front.rb, line 216 def setup_public_interface AVAILABLE_INTERFACES.each do |name, level, need_clear_cache| arg_list = [] arg_list.concat(Utils.arg_list(@canvas.method(name).arity)) arg_str = arg_list.join(", ") if (@public_level & level).zero? instance_eval(<<-EOS, __FILE__, __LINE__ + 1) def self.#{name}(#{arg_str}) raise NotAvailableInterfaceError.new(#{name.to_s.dump}) end EOS else send_arguments = [name.to_s.dump, *arg_list].join(', ') dirty_source = nil dirty_source = "dirty!" if need_clear_cache if (level & PublicLevel::CONTROL).zero? instance_eval(<<-EOS, __FILE__, __LINE__ + 1) def self.#{name}(#{arg_str}) result = @canvas.__send__(#{send_arguments}) #{dirty_source} result end EOS else instance_eval(<<-EOS, __FILE__, __LINE__ + 1) def self.#{name}(#{arg_str}) GLib::Idle.add do @canvas.__send__(#{send_arguments}) #{dirty_source} false end true end EOS end end end end
synchronize()
click to toggle source
# File lib/rabbit/front.rb, line 210 def synchronize @last_modified = @canvas.last_modified @previous_width = @canvas.width @previous_height = @canvas.height end
update_images_if_need()
click to toggle source
# File lib/rabbit/front.rb, line 187 def update_images_if_need mon_synchronize do _check_dirty index = @canvas.current_index if @images[index].nil? prev_size = [@previous_width, @previous_height] current_size = [@canvas.width, @canvas.height] if prev_size != current_size offscreen_canvas.reload_theme end pixbuf = offscreen_canvas.to_pixbuf(index) @images[index] = pixbuf.save_to_buffer(@image_type) synchronize end end end