Class: XAutoBrowse::Window

Inherits:
XTabbedWindow
  • Object
show all
Defined in:
lib/xautobrowse.rb

Instance Method Summary collapse

Constructor Details

#initialize(browser = nil, new_win: true, scan_tabs: false) ⇒ Window

Returns a new instance of Window.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/xautobrowse.rb', line 65

def initialize(browser=nil, new_win: true, scan_tabs: false)
        
  @wm = WMCtrl.instance
  
  if browser then
    
    if new_win then
      spawn(browser.to_s); sleep 3
      
      id = XDo::XWindow.wait_for_window(browser.to_s)

      xwin = XDo::XWindow.new(id)
      title = xwin.title
      puts 'title:  ' + title.inspect if @debug

      # WMCtrl is used because XDo is problematic at trying to activate a window
      
      a = @wm.list_windows true
      puts 'a: '  + a.inspect if @debug
      r = a.reverse.find {|x| x[:title] =~ /#{browser}$/i}
    else
      super(browser, scan_tabs: scan_tabs)
      r = @window
    end
  else
    a = @wm.list_windows true
    r = a.last
  end      
  
  @id = r[:id]

  @x, @y, @width, @height = *r[:geometry]      
  sleep 4 unless browser
  
end

Instance Method Details

#activateObject



101
102
103
# File 'lib/xautobrowse.rb', line 101

def activate()
  @wm.action_window(@id, :activate)
end

#height=(val) ⇒ Object



105
106
107
108
# File 'lib/xautobrowse.rb', line 105

def height=(val)
  @height = val
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end

#move(x, y) ⇒ Object



110
111
112
113
# File 'lib/xautobrowse.rb', line 110

def move(x,y)
  @x, @y = x, y
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end

#resize_to(width, height) ⇒ Object Also known as: resize



115
116
117
118
# File 'lib/xautobrowse.rb', line 115

def resize_to(width, height)
  @width, @height = width, height
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end

#width=(val) ⇒ Object



122
123
124
125
# File 'lib/xautobrowse.rb', line 122

def width=(val)
  @width = val
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end