Sha256: 7e6eb8884106ae01e929136976c2992c5925b67fbced23d97e5545330e2d4f48

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

module Bowline
  module Desktop
    class WindowManager
      extend Bridge::ClassMethods
      js_expose
      
      extend Bowline::Watcher::Base
      watch :on_load
      
      class << self
        def windows
          subclasses.map(&:constantize)
        end
        
        def shown_windows
          windows.select(&:shown?)
        end
        
        def allocated_windows
          windows.select(&:allocated?)
        end
        
        # Methods for subclasses:
        
        def window
          @window
        end
        
        def allocated?
          !!@window
        end
        
        def setup
          return unless Desktop.enabled?
          return if @window && !@window.dealocated?
          if self.name == "MainWindow"
            @window = MainWindow.get
          else
            @window = Window.new
          end
        end
                
        def eval(*args, &block)
          JS.eval(window, *args, &block)
        end
        
        def page
          Proxy.new(window)
        end
        
        def loaded?
          @loaded
        end
        
        def loaded! # :nodoc:
          @loaded = true
          watcher.call(:on_load)
          true
        end
        
        # Delegate most methods to Window
        def method_missing(sym, *args)
          if window && window.respond_to?(sym)
            return window.send(sym, *args)
          end
          # Window won't be around if Bowline::Desktop isn't enabled
          Bowline::Desktop.enabled? ? super : nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bowline-0.5.3 lib/bowline/desktop/window_manager.rb
bowline-0.5.2 lib/bowline/desktop/window_manager.rb
bowline-0.5.1 lib/bowline/desktop/window_manager.rb
bowline-0.5.0 lib/bowline/desktop/window_manager.rb