class Plugin::Openimg::Window

Attributes

photo[R]

Public Class Methods

new(photo, next_opener) click to toggle source
Calls superclass method
# File core/plugin/openimg/window.rb, line 6
def initialize(photo, next_opener)
  super()
  @photo = photo
  @image_surface = loading_surface
  @next_opener = next_opener
  window_settings
  ssc(:destroy, &:destroy)
end

Public Instance Methods

start_loading() click to toggle source
# File core/plugin/openimg/window.rb, line 15
def start_loading
  Thread.new {
    Plugin.filtering(:openimg_pixbuf_from_display_url, photo, nil, nil)
  }.next { |_, pixbufloader, complete_promise|
    if pixbufloader.is_a? GdkPixbuf::PixbufLoader
      rect = nil
      pixbufloader.ssc(:area_updated, self) do |_, x, y, width, height|
        atomic do
          if rect
            rect[:left] = [rect[:left], x].min
            rect[:top] = [rect[:top], y].min
            rect[:right] = [rect[:right], x+width].max
            rect[:bottom] = [rect[:bottom], y+height].max
          else
            rect = {left: x, top: y, right: x+width, bottom: y+height}
            Delayer.new do
              atomic do
                progress(pixbufloader.pixbuf,
                         x: rect[:left],
                         y: rect[:top],
                         width: rect[:right] - rect[:left],
                         height: rect[:bottom] - rect[:top])
                rect = nil
              end
            end
          end
        end
        true
      end

      complete_promise.next{
        progress(pixbufloader.pixbuf, paint: true)
      }.trap { |exception|
        error exception
        @image_surface = error_surface
        redraw(repaint: true)
      }.next {
        pixbufloader.close
      }
    else
      warn "cant open: #{photo}"
      @image_surface = error_surface
      redraw(repaint: true) end
  }.trap{ |exception|
    error exception
    @image_surface = error_surface
    redraw(repaint: true)
  }
  self
end